*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--krome-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--krome-text-primary);
    background-color: var(--krome-bg);
}

a {
    color: var(--krome-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
}

button {
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* Utility classes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--krome-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--krome-transition-fast);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--krome-primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background-color: var(--krome-primary-hover);
}

.btn-secondary {
    background-color: var(--krome-surface);
    color: var(--krome-gray-700);
    border: 1px solid var(--krome-border);
}

.btn-secondary:hover {
    background-color: var(--krome-gray-50);
}

.btn-outline {
    background-color: transparent;
    color: var(--krome-gray-700);
    border: 1px solid var(--krome-border);
}

.btn-outline:hover {
    background-color: var(--krome-gray-50);
}

.btn-link {
    background: none;
    border: none;
    color: var(--krome-primary);
    padding: 0;
    cursor: pointer;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Card styles */
.card {
    background: var(--krome-surface);
    border-radius: var(--krome-radius-lg);
    border: 1px solid var(--krome-border);
    overflow: hidden;
}

/* Form elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    padding: 8px 12px;
    border: 1px solid var(--krome-border);
    border-radius: var(--krome-radius-sm);
    outline: none;
    transition: border-color var(--krome-transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--krome-primary);
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--krome-gray-500);
}

.loading::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--krome-border);
    border-top-color: var(--krome-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Auth checking state (shown by AuthorizeRouteView <Authorizing>) */
.loading-auth {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--krome-bg);
    z-index: 9998;
}

.loading-auth-spinner {
    position: relative;
    width: 48px;
    height: 48px;
}

.loading-auth-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: spin 0.9s linear infinite;
}

.loading-auth-ring:nth-child(1) {
    inset: 0;
    border-top-color: var(--krome-primary);
}

.loading-auth-ring:nth-child(2) {
    inset: 6px;
    border-top-color: #818CF8;
    animation-delay: 0.3s;
}

.loading-auth-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--krome-gray-500);
    letter-spacing: 0.01em;
}

/* 404 Not Found page */
.not-found-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.not-found-content {
    text-align: center;
}

.not-found-content h1 {
    font-size: 72px;
    font-weight: 700;
    color: var(--krome-gray-300);
    line-height: 1;
    margin-bottom: 8px;
}

.not-found-content p {
    font-size: 16px;
    color: var(--krome-gray-500);
    margin: 0 0 24px;
}

.not-found-content a {
    color: var(--krome-primary);
    font-weight: 500;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #fef2f2;
    bottom: 0;
    box-shadow: var(--krome-shadow-sm);
    display: none;
    left: 0;
    padding: 16px;
    position: fixed;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 16px;
}
