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

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    color: #1a1a1a;
    background: #f5f5f5;
    line-height: 1.6;
}

/* Admin layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #1e1e2f;
    color: #ccc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #2d2d44;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #fff;
    font-weight: 700;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0;
    flex: 1;
}

.nav-list li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 0.6rem 1rem;
    color: #b0b0c8;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: #2d2d44;
    color: #fff;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #2d2d44;
    font-size: 0.8rem;
}

.user-email {
    display: block;
    color: #888;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.btn-logout {
    background: transparent;
    color: #b0b0c8;
    border: 1px solid #444;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: #2d2d44;
    color: #fff;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.main-content h1 {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #111;
}

.main-content h2 {
    margin: 1.5rem 0 1rem;
    font-size: 1.35rem;
    font-weight: 600;
    color: #333;
}

.main-content h3 {
    margin: 1rem 0 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #444;
}

/* Login card */
.login-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    margin: 10vh auto;
}

.login-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #111;
}

.login-card .subtitle {
    margin: 0 0 1.75rem;
    color: #666;
    font-size: 0.95rem;
}

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label,
.form-check-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    color: #1a1a1a;
    background: #fff;
    transition: border-color 0.15s;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea.form-control {
    resize: vertical;
}

/* Checkbox */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.form-check .form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
    accent-color: #4f46e5;
}

.form-check .form-check-label {
    margin: 0;
    font-weight: 400;
    color: #1a1a1a;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: #4f46e5;
    color: #fff;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    background: #4338ca;
}

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

.btn-link {
    background: none;
    color: #4f46e5;
    padding: 0;
    font-weight: 600;
    text-decoration: none;
}

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

.form-actions {
    margin-top: 1.5rem;
}

.form-actions .btn-primary {
    width: auto;
    padding: 0.65rem 2rem;
}

/* Alerts */
.alert {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table code {
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Email templates: placeholder hints, read-only key */
.form-hint {
    color: #666;
    font-size: 0.8rem;
    margin: 0.35rem 0 0;
}

.readonly-value {
    margin: 0;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    color: #444;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
}

.placeholder-hints {
    list-style: none;
    margin: 0;
    padding: 0;
}

.placeholder-hints li {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.placeholder-hints code {
    font-weight: 600;
    color: #4f46e5;
}

.placeholder-requirement {
    margin-left: 0.5rem;
    color: #666;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.placeholder-description,
.placeholder-example {
    display: block;
    color: #555;
    margin-top: 0.2rem;
}

.placeholder-example {
    color: #777;
    font-size: 0.78rem;
}

/* Detail card */
.detail-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}

.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.detail-list dt {
    font-weight: 600;
    color: #555;
    font-size: 0.875rem;
}

.detail-list dd {
    margin: 0;
    font-size: 0.9rem;
}

/* Badge */
.badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-status {
    background: #e5e7eb;
    color: #555;
}

.form-control-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1.5px solid #d1d5db;
    background: #fff;
    cursor: pointer;
}

/* Loading state */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 1rem;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Validation */
.validation-message {
    color: #b91c1c;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.valid.modified:not([type=checkbox]) {
    border-color: #16a34a;
}

.invalid {
    border-color: #dc2626 !important;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #fef2f2;
    border-top: 1px solid #fecaca;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #b91c1c;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Loading progress */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #4f46e5;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, 'Loading');
}

/* Mobile */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .sidebar-header {
        border-bottom: none;
        padding: 0.75rem 1rem;
    }

    .nav-list {
        display: flex;
        padding: 0;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
    }

    .sidebar-footer {
        border-top: none;
        margin-left: auto;
    }

    .main-content {
        padding: 1rem;
    }
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-bar label {
    font-weight: 500;
    white-space: nowrap;
}

.filter-select {
    max-width: 220px;
}

/* Role badges */
.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: #dbeafe;
    color: #1d4ed8;
    margin-right: 0.25rem;
}

.role-badge.role-none {
    background-color: transparent;
    color: #9ca3af;
    font-weight: 400;
}

/* Typeahead / user search */
.typeahead-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    position: absolute;
    z-index: 100;
    min-width: 300px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.typeahead-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.typeahead-item:hover {
    background-color: #eff6ff;
}

.typeahead-secondary {
    color: #6b7280;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}
