/* ============================================================================
   CRAFTIVIA SAAS — SCHOLAR'S PARCHMENT DESIGN SYSTEM (PERPLEXITY AI STYLE)
   "scholar's parchment behind clean glass"
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    /* ------------------------------------------------------------------------
       1. Core Design Tokens (Perplexity AI Style Reference)
       ------------------------------------------------------------------------ */
    --color-parchment: #faf8f5;        /* Page canvas, main background */
    --color-soft-paper: #fdfbfa;       /* Card surfaces, elevated layers */
    --color-warm-mist: #d1d1cd;        /* Hairline borders (pencil line on paper) */
    --color-ash: #92918b;              /* Micro helper text, muted labels */
    --color-graphite: #72706b;         /* Secondary text, nav icons, inactive */
    --color-ink: #27251e;              /* Primary text, filled button fill */
    --color-pure-black: #000000;       /* High-contrast accents */
    --color-deep-teal: #016a71;        /* Single chromatic accent: nav active, badge */

    /* Typography Scale */
    --font-pplxsans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --text-caption: 11px;
    --leading-caption: 1.43;
    --text-body-sm: 12px;
    --leading-body-sm: 1.43;
    --text-body: 14px;
    --leading-body: 1.43;
    --text-body-lg: 16px;
    --leading-body-lg: 1.5;

    /* Typographic Weights (Strictly 400 - 500) */
    --font-weight-regular: 400;
    --font-weight-medium: 500;

    /* Spacing & Layout */
    --spacing-unit: 4px;
    --spacing-4: 4px;
    --spacing-8: 8px;
    --spacing-12: 12px;
    --spacing-16: 16px;
    --spacing-24: 24px;
    --spacing-32: 32px;
    --page-max-width: 900px;

    /* Border Radii */
    --radius-cards: 16px;
    --radius-chips: 9999px;
    --radius-inputs: 12px;
    --radius-buttons: 12px;
    --radius-ghost: 6px;

    /* Elevation (Intentionally flat: single subtle 1px shadow) */
    --shadow-subtle: rgba(0, 0, 0, 0.08) 0px 1px 2px 0px;

    /* ------------------------------------------------------------------------
       2. Platform Semantic Theme Mapping (Craftivia Compatibility)
       ------------------------------------------------------------------------ */
    --color-primary: #016a71;          /* Deep Teal */
    --color-secondary: #27251e;        /* Ink */
    --color-accent: #016a71;           /* Deep Teal */
    --color-neutral: #faf8f5;          /* Parchment */
    --color-surface: #fdfbfa;          /* Soft Paper */
    --color-card: #fdfbfa;             /* Soft Paper */
    --color-border: #d1d1cd;           /* Warm Mist */
    --color-dark: #27251e;             /* Ink */
    --color-text: #27251e;             /* Ink */
    --color-muted: #72706b;            /* Graphite */

    --color-primary-rgb: 1, 106, 113;
    --color-secondary-rgb: 39, 37, 30;
    --color-neutral-rgb: 250, 248, 245;
}

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

[x-cloak] {
    display: none !important;
}

/* Base Body & Reset */
html, body, input, textarea, select, button {
    font-family: var(--font-pplxsans);
    font-weight: var(--font-weight-regular);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: 0;
}

body {
    background-color: var(--color-parchment) !important;
    color: var(--color-ink) !important;
    line-height: var(--leading-body);
}

/* Material Symbols Helper */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 1.25rem;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    vertical-align: middle;
}

/* Custom Scrollbar - Flat Warm Mist */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--color-warm-mist);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-graphite);
}

::selection {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
}

/* ============================================================================
   3. COMPONENTS — PERPLEXITY STYLE SPECIFICATIONS
   ============================================================================ */

/* A. Cards (Soft Paper #fdfbfa, 16px radius, hairline border, subtle shadow) */
.bento-card,
.card-surface,
.parchment-card {
    background-color: var(--color-soft-paper) !important;
    border-radius: var(--radius-cards) !important;
    border: 1px solid var(--color-warm-mist) !important;
    box-shadow: var(--shadow-subtle) !important;
    padding: var(--spacing-16);
    transition: border-color 0.15s ease;
}

.bento-card:hover {
    border-color: var(--color-ash) !important;
}

.bento-card-subtle {
    background-color: var(--color-parchment) !important;
    border-radius: var(--radius-cards) !important;
    border: 1px solid var(--color-warm-mist) !important;
}

/* B. Filled Action Button (Deep Teal #016a71 background, Parchment #faf8f5 text, 12px radius) */
.btn-luxury,
.btn-filled,
.btn-ink {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
    border-radius: var(--radius-buttons) !important;
    border: 1px solid var(--color-deep-teal) !important;
    padding: 8px 14px !important;
    font-size: var(--text-body) !important;
    font-weight: var(--font-weight-medium) !important;
    line-height: var(--leading-body) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-subtle) !important;
    transition: background-color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
}

.btn-luxury:hover,
.btn-filled:hover,
.btn-ink:hover {
    background-color: #015257 !important;
    border-color: #015257 !important;
    color: #ffffff !important;
}

.btn-luxury:active,
.btn-filled:active,
.btn-ink:active {
    transform: scale(0.98);
}

/* C. Ghost Button (Transparent, Graphite text, 1px Warm Mist border, 6px radius) */
.btn-ghost {
    background-color: transparent !important;
    color: var(--color-graphite) !important;
    border: 1px solid var(--color-warm-mist) !important;
    border-radius: var(--radius-ghost) !important;
    padding: 8px 12px !important;
    font-size: var(--text-body) !important;
    font-weight: var(--font-weight-regular) !important;
    line-height: var(--leading-body) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
}

.btn-ghost:hover {
    color: var(--color-ink) !important;
    border-color: var(--color-ash) !important;
    background-color: var(--color-soft-paper) !important;
}

.btn-ghost:active {
    transform: scale(0.98);
}

/* D. Deep Teal Accent Button (Brand action button) */
.btn-teal {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
    border-radius: var(--radius-buttons) !important;
    border: 1px solid transparent !important;
    padding: 8px 14px !important;
    font-size: var(--text-body) !important;
    font-weight: var(--font-weight-medium) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-subtle) !important;
    transition: opacity 0.15s ease;
    cursor: pointer;
}

.btn-teal:hover {
    opacity: 0.92;
}

/* E. Pill Chips (Search modes, status filters — 9999px radius) */
.pill-chip,
.chip-pill {
    background-color: transparent;
    color: var(--color-ink);
    border: 1px solid var(--color-warm-mist);
    border-radius: var(--radius-chips) !important;
    padding: 8px 12px;
    font-size: var(--text-body);
    font-weight: var(--font-weight-regular);
    line-height: var(--leading-body);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.pill-chip:hover,
.chip-pill:hover {
    border-color: var(--color-ash);
    background-color: var(--color-soft-paper);
}

.pill-chip.active,
.chip-pill.active,
.pill-chip-active {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
    border-color: var(--color-deep-teal) !important;
}

/* F. Badge Tag / "NEW" indicator (Deep Teal, 9999px pill, 11px font) */
.badge-tag,
.badge-new,
.badge-teal {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
    border-radius: var(--radius-chips) !important;
    padding: 2px 8px !important;
    font-size: var(--text-caption) !important;
    font-weight: var(--font-weight-medium) !important;
    line-height: 1.5 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.02em;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-chips);
    font-size: var(--text-caption);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid var(--color-warm-mist);
    background-color: var(--color-soft-paper);
    color: var(--color-graphite);
}

.badge-pill.active,
.badge-pill-success {
    background-color: rgba(1, 106, 113, 0.12) !important;
    color: var(--color-deep-teal) !important;
    border-color: rgba(1, 106, 113, 0.3) !important;
}

/* G. Form Inputs (Parchment #faf8f5, 12px radius, hairline Warm Mist border) */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not(.input-seamless),
select,
textarea,
.input-luminous {
    background-color: var(--color-parchment) !important;
    border: 1px solid var(--color-warm-mist) !important;
    border-radius: var(--radius-inputs) !important;
    color: var(--color-ink) !important;
    font-size: var(--text-body) !important;
    font-weight: var(--font-weight-regular) !important;
    padding: 10px 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Seamless input inside flex input groups (no inner border, no inner box, no background collision) */
input.input-seamless {
    background-color: transparent !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 10px 8px !important;
    color: var(--color-ink) !important;
    font-size: var(--text-body) !important;
}

input.input-seamless:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
}

/* Browser Autofill Styling */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #faf8f5 inset !important;
    -webkit-text-fill-color: #27251e !important;
    border-color: #d1d1cd !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not(.input-seamless)::placeholder,
textarea::placeholder {
    color: var(--color-graphite) !important;
    opacity: 0.85;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not(.input-seamless):focus,
select:focus,
textarea:focus,
.input-luminous:focus {
    border-color: var(--color-deep-teal) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(1, 106, 113, 0.15) !important;
    background-color: var(--color-soft-paper) !important;
}

/* iOS Safari Date/Time Fix */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
    text-align: left;
    line-height: 1.4;
    min-height: 1.4em;
    margin: 0;
    padding: 0;
}

/* H. Hero Search / Focal Input (Teal glow border & parchment fill) */
.search-hero-box {
    background-color: var(--color-parchment);
    border: 1px solid var(--color-warm-mist);
    border-radius: var(--radius-inputs);
    padding: 14px 16px;
    box-shadow: 0 0 0 1px rgba(1, 106, 113, 0.12), var(--shadow-subtle);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-hero-box:focus-within {
    border-color: var(--color-deep-teal);
    box-shadow: 0 0 0 3px rgba(1, 106, 113, 0.2);
}

/* I. Sidebar Nav Item */
.sidebar-nav-item {
    background-color: transparent;
    color: var(--color-graphite);
    border: none;
    border-radius: var(--radius-inputs);
    padding: 8px 12px;
    font-size: var(--text-body-lg);
    font-weight: var(--font-weight-regular);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
}

.sidebar-nav-item:hover {
    color: var(--color-ink);
    background-color: var(--color-soft-paper);
}

.sidebar-nav-item.active {
    background-color: var(--color-deep-teal) !important;
    color: #ffffff !important;
}

/* J. Clean Glass Surface (Clean subtle translucent barrier) */
.glass-surface,
.glass-surface-warm {
    background: rgba(250, 248, 245, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-warm-mist) !important;
}

/* K. Modal Dialog Backdrop & Card */
.modal-backdrop {
    background-color: rgba(39, 37, 30, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content,
.modal-sheet-content {
    background-color: var(--color-soft-paper) !important;
    border: 1px solid var(--color-warm-mist) !important;
    border-radius: var(--radius-cards) !important;
    box-shadow: 0 10px 25px -5px rgba(39, 37, 30, 0.1) !important;
}

@media (max-width: 639px) {
    .modal-sheet-content {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
    }
}

/* L. Status Dot Pulse */
.status-dot-pulse {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    display: inline-block;
    position: relative;
}
.status-dot-pulse::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 9999px;
    background-color: inherit;
    opacity: 0.5;
    animation: ping-subtle 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping-subtle {
    75%, 100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* M. Table Rows & Clean Dividers */
.table-row-hover:hover {
    background-color: var(--color-parchment) !important;
}

table thead th {
    background-color: var(--color-parchment) !important;
    color: var(--color-graphite) !important;
    border-bottom: 1px solid var(--color-warm-mist) !important;
    font-weight: var(--font-weight-medium) !important;
    font-size: var(--text-body-sm) !important;
}

.border-warm-mist {
    border-color: var(--color-warm-mist) !important;
}

/* ============================================================================
   4. ACCESSIBILITY & PRINT SPECIFICATIONS
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .no-print, header, nav, .btn-print-controls, .modal-backdrop {
        display: none !important;
    }
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    #print-container {
        display: block !important;
        background: #ffffff !important;
    }
    body.paper-58mm { width: 58mm !important; }
    body.paper-58mm #print-container { width: 54mm !important; font-size: 10px !important; }
    body.paper-80mm { width: 80mm !important; }
    body.paper-80mm #print-container { width: 72mm !important; font-size: 12px !important; }
    body.paper-standard #print-container { max-width: 180mm !important; font-size: 13px !important; }
    .thermal-divider { border-top: 1px dashed #000000 !important; margin: 6px 0 !important; }
    .thermal-divider-double { border-top: 1px double #000000 !important; margin: 6px 0 !important; }
}
