/* ════════════════════════════════════════════════════════════════════
   Project-level overrides. Brand design system (colors, fonts) is in the
   Tailwind config + <style> block in App.razor. This file holds CSS
   variables, form defaults, and the component layer.

   NOTE: element selectors are wrapped in :where() so their specificity is
   ZERO — that lets Tailwind utilities (pl-9, bg-white, border-slate-300,
   py-2, ...) override them. Without :where(), `input[type="text"]` (0,1,1)
   beats `.pl-9` (0,1,0) and the utility silently does nothing.
   ════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design-system CSS Variables (match React index.css exactly) ── */
:root {
    --background: 220 22% 97%; /* page bg #f7f8fa */
    --foreground: 219 55% 16%; /* ink navy #12213f */
    --card: 0 0% 100%;
    --card-foreground: 219 55% 16%;
    --popover: 0 0% 100%;
    --popover-foreground: 219 55% 16%;
    --primary: 217 61% 26%; /* navy #1a3a6b — nav/buttons/links */
    --primary-foreground: 0 0% 100%;
    --secondary: 217 60% 22%; /* #16305a */
    --secondary-foreground: 0 0% 100%;
    --muted: 220 25% 94%; /* mint #eef1f6 */
    --muted-foreground: 219 20% 42%;
    --accent: 36 30% 51%; /* tan/brown-gold #a98d5d — headers/titles */
    --accent-foreground: 0 0% 100%;
    --destructive: 355 67% 42%; /* red-alert #b52432 */
    --destructive-foreground: 0 0% 100%;
    --border: 220 24% 89%; /* #dbe0ea */
    --input: 220 24% 89%;
    --ring: 217 61% 26%; /* navy #1a3a6b */
    --radius: 0.5rem;
    --warning: 36 30% 51%; /* tan-gold #a98d5d */
    --success: 160 55% 36%;
    --info: 217 61% 26%; /* navy #1a3a6b */
    /* sidebar — deep navy (matches nav/footer) */
    --sidebar-background: 219 59% 12%; /* forest #0d1a33 */
    --sidebar-foreground: 220 24% 80%;
    --sidebar-primary: 36 30% 51%; /* tan-gold — logo + active link */
    --sidebar-primary-foreground: 219 59% 8%;
    --sidebar-accent: 217 61% 26%; /* navy #1a3a6b */
    --sidebar-accent-foreground: 220 25% 95%;
    --sidebar-border: 217 40% 22%;
    --sidebar-muted: 219 18% 55%;
    --kpi-gradient-1: linear-gradient(135deg, hsl(219 55% 16%), hsl(217 60% 22%)); /* ink → navy */
    --kpi-gradient-2: linear-gradient(135deg, hsl(217 61% 26%), hsl(217 60% 22%)); /* navy → navy */
    --kpi-gradient-3: linear-gradient(135deg, hsl(36 32% 42%), hsl(36 34% 56%)); /* tan-dark → tan */
    --kpi-gradient-4: linear-gradient(135deg, hsl(217 61% 26%), hsl(219 55% 16%)); /* navy → ink */
    --gold: 36 30% 51%; /* tan/brown-gold #a98d5d */
    --gold-foreground: 219 59% 8%;
}

/* ── Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    border-color: hsl(var(--border));
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* ── Semantic color utilities (used via inline style workaround since Tailwind CDN doesn't have our vars) ── */
.bg-background {
    background: hsl(var(--background));
}

.bg-card {
    background: hsl(var(--card));
}

.bg-muted {
    background: hsl(var(--muted));
}

.bg-primary {
    background: hsl(var(--primary));
}

.bg-accent {
    background: hsl(var(--accent));
}

.text-foreground {
    color: hsl(var(--foreground));
}

.text-card-foreground {
    color: hsl(var(--card-foreground));
}

.text-muted-foreground {
    color: hsl(var(--muted-foreground));
}

.text-primary {
    color: hsl(var(--primary));
}

.text-accent {
    color: hsl(var(--accent));
}

.text-destructive {
    color: hsl(var(--destructive));
}

.border-border {
    border-color: hsl(var(--border));
}

.border-input {
    border-color: hsl(var(--input));
}

.ring-ring {
    --tw-ring-color: hsl(var(--ring));
}

/* ── KPI Cards ── */
.kpi-card {
    border-radius: .75rem;
    padding: 1.25rem;
    color: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0/.1),0 2px 4px -2px rgb(0 0 0/.1);
    transition: all .3s;
}

    .kpi-card:hover {
        box-shadow: 0 10px 15px -3px rgb(0 0 0/.1),0 4px 6px -4px rgb(0 0 0/.1);
        transform: translateY(-2px);
    }

.kpi-card-navy {
    background: var(--kpi-gradient-1);
}

.kpi-card-teal {
    background: var(--kpi-gradient-2);
}

.kpi-card-amber {
    background: var(--kpi-gradient-3);
}

.kpi-card-blue {
    background: var(--kpi-gradient-4);
}

/* ── Sidebar ── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    border-radius: .5rem;
    padding: .625rem .75rem;
    font-size: .875rem;
    font-weight: 500;
    transition: all .2s;
    color: hsl(var(--sidebar-foreground));
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

    .sidebar-link:hover {
        background: hsl(var(--sidebar-accent));
        color: hsl(var(--sidebar-accent-foreground));
    }

    .sidebar-link.active {
        background: hsl(var(--sidebar-accent));
        color: hsl(var(--sidebar-primary));
    }

/* ── Status Badges ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: .125rem .625rem;
    font-size: .75rem;
    font-weight: 500;
}

.status-submitted {
    background: #dbeafe;
    color: #1e40af;
}

.status-review {
    background: #fef3c7;
    color: #8a5a06;
}

.status-accepted {
    background: #d3f2e2;
    color: #0d5238;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-revision {
    background: #ece9fb;
    color: #4c3b96;
}

.status-screening {
    background: #eef2f0;
    color: #40534b;
}

.status-production {
    background: #d3f2e2;
    color: #0d5238;
}

.status-info {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-warning {
    background: #fdf3c8;
    color: #8a5a06;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.status-success {
    background: #d3f2e2;
    color: #0d5238;
}

/* ── Data Table Row ── */
.data-table-row {
    border-bottom: 1px solid hsl(var(--border));
    transition: background .15s;
}

    .data-table-row:hover {
        background: hsl(var(--muted)/.5);
    }

/* ── Card ── */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: .75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0/.1);
}

/* ── Buttons ── */
.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
}

    .btn-primary:hover {
        background: hsl(220 60% 24%);
    }

.btn-outline {
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

    .btn-outline:hover {
        background: hsl(var(--muted));
    }

.btn-accent {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    border: none;
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    border: none;
}

/* ── Input ── */
.input-field {
    display: block;
    width: 100%;
    border-radius: .5rem;
    border: 1px solid hsl(var(--input));
    background: hsl(var(--card));
    padding: .5rem .75rem;
    font-size: .875rem;
    color: hsl(var(--foreground));
    outline: none;
}

    .input-field:focus {
        border-color: hsl(var(--ring));
        box-shadow: 0 0 0 2px hsl(var(--ring)/.2);
    }

    .input-field::placeholder {
        color: hsl(var(--muted-foreground));
    }

/* ── Tab (vertical) ── */
.tab-vertical {
    display: flex;
    align-items: center;
    gap: .5rem;
    border-radius: .5rem;
    padding: .625rem .75rem;
    font-size: .75rem;
    font-weight: 500;
    transition: all .15s;
    cursor: pointer;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: hsl(var(--foreground));
}

    .tab-vertical:hover {
        background: hsl(var(--muted));
    }

    .tab-vertical.active {
        background: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
    }

/* ── Horizontal Tab ── */
.tab-h {
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    transition: all .15s;
    cursor: pointer;
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    border-bottom: 2px solid transparent;
}

    .tab-h:hover {
        color: hsl(var(--foreground));
    }

    .tab-h.active {
        color: hsl(var(--primary));
        border-bottom-color: hsl(var(--primary));
    }

/* ── Progress ── */
.progress-bar {
    height: 6px;
    border-radius: 3px;
    background: hsl(var(--muted));
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: hsl(var(--accent));
    transition: width .3s ease;
}

/* ── Mono ── */
.mono-text {
    font-family: 'JetBrains Mono',monospace;
}

/* ── Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(.95)
    }

    to {
        opacity: 1;
        transform: scale(1)
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%)
    }

    to {
        transform: translateX(0)
    }
}

.animate-fade-in {
    animation: fadeIn .4s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn .15s ease-out;
}

.animate-slide-in {
    animation: slideIn .3s ease-out;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: 3px;
}

/* ── Dialog Backdrop ── */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0/.45);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .75rem;
    animation: fadeIn .15s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dialog-box {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: .75rem;
    box-shadow: 0 20px 60px -10px rgb(0 0 0/.4);
    animation: scaleIn .2s ease-out;
    padding: 1rem;
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 640px) {
    .dialog-backdrop {
        padding: 1rem;
    }

    .dialog-box {
        padding: 1.5rem;
    }
}

/* Nested dialogs (sub-dialogs within detail modal) */
.dialog-backdrop.nested {
    z-index: 60;
}

    .dialog-backdrop.nested .dialog-box {
        max-width: 28rem;
    }

/* ── Section header ── */
.section-header {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* ── Filter pill ── */
.filter-pill {
    border-radius: .5rem;
    padding: .375rem .75rem;
    font-size: .75rem;
    font-weight: 500;
    transition: all .15s;
    cursor: pointer;
}

    .filter-pill.active {
        background: hsl(var(--primary));
        color: hsl(var(--primary-foreground));
        border-color: hsl(var(--primary));
    }

    .filter-pill.inactive {
        background: hsl(var(--card));
        color: hsl(var(--card-foreground));
        border: 1px solid hsl(var(--border));
    }

        .filter-pill.inactive:hover {
            background: hsl(var(--muted));
        }

/* ── Form label & input used in Master pages ── */
.lbl {
    display: block;
    font-size: .75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: .25rem;
}

.inp {
    display: block;
    width: 100%;
    border-radius: .5rem;
    border: 1px solid hsl(var(--input));
    background: hsl(var(--card));
    padding: .5rem .75rem;
    font-size: .875rem;
    color: hsl(var(--foreground));
    outline: none;
}

    .inp:focus {
        border-color: hsl(var(--ring));
        box-shadow: 0 0 0 2px hsl(var(--ring)/.2);
    }

    .inp::placeholder {
        color: hsl(var(--muted-foreground));
    }

/* ── Badge variants (mirror React Badge) ── */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: calc(var(--radius) - 2px);
    padding: .125rem .5rem;
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.badge-outline {
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
    background: transparent;
}

.badge-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

/* ── Ghost icon button ── */
.btn-ghost-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .375rem;
    padding: .375rem;
    background: none;
    border: none;
    cursor: pointer;
    color: hsl(var(--muted-foreground));
    transition: all .15s;
}

    .btn-ghost-icon:hover {
        background: hsl(var(--muted));
    }

    .btn-ghost-icon.danger:hover {
        background: #fee2e2;
        color: #dc2626;
    }

/* ── Thead muted bg ── */
.thead-muted {
    background: hsl(var(--muted)/.5);
}

/* thead fallback if opacity not supported */
.bg-muted-half {
    background: hsl(215 22% 91%);
}

/* ── Tab nav inside scrollable containers — prevent wrapping ── */
.overflow-x-auto > button,
.overflow-x-auto > a {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Responsive Table Utilities ── */

/* Compact table cells on mobile */
@media (max-width: 767px) {
    .resp-table th,
    .resp-table td {
        padding: .5rem .625rem;
        font-size: .75rem;
    }

    .resp-table th {
        font-size: .6875rem;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .resp-table th,
    .resp-table td {
        padding: .5rem .75rem;
    }
}

/* ── Mobile & Tablet Responsive ── */

/* Touch-friendly tap targets */
@media (max-width: 640px) {
    /* Scale down h1 on mobile */
    h1 {
        font-size: 1.25rem !important; /* text-xl */
    }

    /* Scale down h2 section headers */
    h2 {
        font-size: 1.125rem !important;
    }

    .sidebar-link {
        padding: .75rem;
        font-size: .8125rem;
    }

    .kpi-card {
        padding: 1rem;
    }


    .filter-pill {
        padding: .5rem .875rem;
        font-size: .8125rem;
    }

    .tab-h {
        padding: .5rem .75rem;
        font-size: .8125rem;
        white-space: nowrap;
    }

    .status-badge {
        font-size: .6875rem;
        padding: .125rem .5rem;
    }

    .section-header {
        font-size: 1rem;
    }

    .btn-primary, .btn-outline, .btn-accent, .btn-destructive {
        padding: .5rem 1rem;
        font-size: .8125rem;
    }

    .input-field, .inp {
        font-size: 1rem; /* Prevent iOS zoom on focus */
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1023px) {
    .dialog-box {
        max-width: 90vw;
    }
}

/* Safe area insets for iOS notch/home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .min-h-screen {
        min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}

/* Improve scrollbar for touch devices */
@media (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 3px;
        height: 3px;
    }

    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
}
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
    outline: none;
}