/* ===================================================================
   SafePrep Design System — Inspired by SafeServe modern UI
   =================================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Colors — HSL based */
    --background: #ffffff;
    --foreground: #1d2530;
    --card: #ffffff;
    --card-foreground: #1d2530;
    --primary: #1479b8;
    --primary-light: #e8f4fc;
    --primary-foreground: #ffffff;
    --secondary: #edf3f8;
    --secondary-foreground: #0b578e;
    --muted: #f3f5f7;
    --muted-foreground: #6b7a8d;
    --accent: #dceaf5;
    --accent-foreground: #0b578e;
    --destructive: #dc2626;
    --destructive-light: #fef2f2;
    --destructive-foreground: #ffffff;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --success-foreground: #ffffff;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --warning-foreground: #ffffff;
    --border: #e0e5eb;
    --input-border: #d1d9e0;
    --ring: #1479b8;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    /* Sidebar */
    --sidebar-bg: #f6f8fa;
    --sidebar-foreground: #303d50;
    --sidebar-primary: #1479b8;
    --sidebar-active-bg: #ffffff;
    --sidebar-active-text: #1479b8;
    --sidebar-hover-bg: #edf0f3;
    --sidebar-width: 250px;
    --sidebar-section-color: #8b95a5;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

    /* Typography */
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    font-family: var(--font-body);
    color: var(--foreground);
    background-color: var(--background);
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.3;
    margin-top: 0;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--secondary-foreground);
}

p { margin-bottom: 1rem; }

/* --- Focus States --- */
:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

h1:focus { outline: none; }

/* --- Cards --- */
.sfbb-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 1.5rem;
    transition: box-shadow var(--transition-normal);
}
.sfbb-card:hover {
    box-shadow: var(--shadow-sm);
}
.sfbb-card-header {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sfbb-card-header .card-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-body);
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: #1068a3;
    border-color: #1068a3;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background-color: var(--success);
    color: var(--success-foreground);
    border-color: var(--success);
}
.btn-success:hover, .btn-success:focus {
    background-color: #138a3e;
    border-color: #138a3e;
    color: #fff;
}

.btn-danger, .btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
}
.btn-danger:hover, .btn-danger:focus {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.btn-warning {
    background-color: var(--warning);
    color: #fff;
    border-color: var(--warning);
}
.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
    color: #fff;
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--muted-foreground);
    border: 1px solid var(--border);
}
.btn-outline-secondary:hover {
    background: var(--muted);
    color: var(--foreground);
}

.btn-ghost {
    background: transparent;
    color: var(--muted-foreground);
    border: none;
    padding: 0.375rem 0.75rem;
}
.btn-ghost:hover {
    background: var(--muted);
    color: var(--foreground);
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.625rem 1.5rem;
    font-size: 1rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus {
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

/* --- Form Controls --- */
.form-control, .form-select {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--foreground);
    background-color: var(--background);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.5;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 121, 184, 0.15);
    outline: none;
}
.form-control::placeholder {
    color: var(--muted-foreground);
    opacity: 0.7;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--foreground);
    margin-bottom: 0.375rem;
}

.form-check-input {
    border-color: var(--input-border);
    border-radius: 4px;
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(20, 121, 184, 0.15);
    border-color: var(--primary);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* --- Badges / Pills --- */
.badge {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    line-height: 1.4;
}

.badge-success, .badge.bg-success {
    background-color: var(--success-light) !important;
    color: var(--success) !important;
}
.badge-danger, .badge.bg-danger {
    background-color: var(--destructive-light) !important;
    color: var(--destructive) !important;
}
.badge-warning, .badge.bg-warning {
    background-color: var(--warning-light) !important;
    color: #92400e !important;
}
.badge-info, .badge.bg-info {
    background-color: var(--primary-light) !important;
    color: var(--primary) !important;
}
.badge-secondary, .badge.bg-secondary {
    background-color: var(--muted) !important;
    color: var(--muted-foreground) !important;
}
.badge-primary, .badge.bg-primary {
    background-color: var(--primary) !important;
    color: var(--primary-foreground) !important;
}

/* Status-specific badges */
.status-complete {
    color: var(--success);
    font-weight: 600;
    font-size: 0.875rem;
}
.status-pending {
    color: var(--warning);
    font-weight: 600;
    font-size: 0.875rem;
}
.status-overdue {
    color: var(--destructive);
    font-weight: 600;
    font-size: 0.875rem;
}

/* --- Tables --- */
.sfbb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sfbb-table thead th {
    background: var(--muted);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted-foreground);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.sfbb-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
    vertical-align: middle;
}
.sfbb-table tbody tr:last-child td {
    border-bottom: none;
}
.sfbb-table tbody tr:hover {
    background-color: var(--muted);
}

/* Also override Bootstrap tables */
.table {
    border-collapse: separate;
    border-spacing: 0;
}
.table > thead > tr > th {
    background: var(--muted);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}
.table > tbody > tr > td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table > tbody > tr:hover {
    background-color: rgba(0,0,0,0.015);
}

/* --- Alerts --- */
.alert {
    border-radius: var(--radius);
    border: 1px solid;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
}
.alert-success {
    background-color: var(--success-light);
    border-color: #bbf7d0;
    color: #166534;
}
.alert-warning {
    background-color: var(--warning-light);
    border-color: #fde68a;
    color: #92400e;
}
.alert-danger {
    background-color: var(--destructive-light);
    border-color: #fecaca;
    color: #991b1b;
}
.alert-info {
    background-color: var(--primary-light);
    border-color: #bae6fd;
    color: #075985;
}

/* --- Progress Bar --- */
.progress {
    background-color: var(--muted);
    border-radius: 9999px;
    overflow: hidden;
}
.progress-bar {
    border-radius: 9999px;
    transition: width 0.6s ease;
}
.progress-bar.bg-success {
    background-color: var(--success) !important;
}

/* --- Tabs --- */
.sfbb-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.sfbb-tab {
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--muted-foreground);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.sfbb-tab:hover {
    color: var(--foreground);
}
.sfbb-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* --- Page Layout Helpers --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    margin-bottom: 0;
}
.page-subtitle {
    color: var(--muted-foreground);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

.content-grid {
    display: grid;
    gap: 1.25rem;
}
.content-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 768px) {
    .content-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}
.content-grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 768px) {
    .content-grid-3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* --- Checklist Items --- */
.check-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--muted);
    font-size: 0.9375rem;
}
.check-item:last-child {
    border-bottom: none;
}
.check-icon {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.check-icon.checked {
    background-color: var(--primary);
    color: white;
}
.check-icon.unchecked {
    border: 2px solid var(--input-border);
    background: transparent;
}

/* --- Stat Cards --- */
.stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

/* --- Empty States --- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--muted-foreground);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state p {
    font-size: 0.9375rem;
    max-width: 400px;
    margin: 0 auto 1rem;
}

/* --- Loading Spinner --- */
.sfbb-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}
.spinner-border {
    color: var(--primary) !important;
    width: 2rem;
    height: 2rem;
}

/* --- List Groups --- */
.list-group-item {
    border-color: var(--border);
    padding: 0.875rem 1rem;
}
.list-group-item:first-child {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}
.list-group-item:last-child {
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* --- Validation --- */
.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: var(--success);
}
.invalid {
    outline: none;
    border-color: var(--destructive);
}
.validation-message {
    color: var(--destructive);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* --- Error Boundary --- */
.blazor-error-boundary {
    background: var(--destructive);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--radius);
}
.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

/* --- Override Bootstrap card styles to match our theme --- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.card-header {
    background-color: var(--muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 0.875rem 1.25rem;
}
.card-body {
    padding: 1.25rem;
}
.card-header.bg-primary {
    background-color: var(--primary) !important;
}
.card-header.bg-success {
    background-color: var(--success) !important;
}

/* --- Responsive Table Wrapper --- */
.table-responsive {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* --- Utility Classes --- */
.text-muted { color: var(--muted-foreground) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--destructive) !important; }
.text-warning { color: #b45309 !important; }
.gap-xs { gap: 0.375rem; }
.gap-sm { gap: 0.625rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.border-success { border-color: var(--success) !important; }
.border-primary { border-color: var(--primary) !important; }
.border-warning { border-color: var(--warning) !important; }

/* --- Mobile Responsiveness --- */
@media (max-width: 640px) {
    html, body {
        font-size: 14px;
    }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    .sfbb-card { padding: 1rem; }
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .sfbb-table thead th,
    .sfbb-table tbody td {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f1f5f9;
    padding: 1rem;
}

.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0.75rem 0 0.25rem;
}

.auth-header p {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.auth-footer p {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

.auth-footer a {
    color: #1479b8;
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Safe Method Question Forms */
.question-field {
    margin-bottom: 0.25rem;
}

.question-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.yes-no-toggle {
    display: flex;
    gap: 0.5rem;
}

.yes-no-toggle button {
    padding: 0.375rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--input-border, #d1d5db);
}

.checklist-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    line-height: 1.4;
}

.checklist-item input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    accent-color: var(--primary, #1479b8);
}
