/* ==========================================================================
   C&N Money Exchange - Core CSS Design System (LIGHT THEME)
   Aesthetics: Clean Corporate, High-Contrast Slate, Senior-Friendly, Premium
   ========================================================================== */

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

:root {
    /* Color Palette - HIGHLegibility Light Theme */
    --bg-primary: #f8fafc;      /* Slate 50 - Main background */
    --bg-secondary: #ffffff;    /* Pure White - Card background */
    --bg-tertiary: #f1f5f9;     /* Slate 100 - Headers / Sidebar */
    --card-bg: #ffffff;
    --card-bg-hover: #f8fafc;
    --card-border: #cbd5e1;     /* Slate 300 - Thick, high legibility border */
    --card-border-hover: #94a3b8; /* Slate 400 */
    
    /* Accents (Saturated and Deep for high-contrast on white) */
    --accent-cyan: #0284c7;      /* Sky 600 */
    --accent-cyan-glow: rgba(2, 132, 199, 0.15);
    --accent-emerald: #059669;   /* Emerald 600 (Buy/Profit) */
    --accent-emerald-glow: rgba(5, 150, 105, 0.15);
    --accent-rose: #dc2626;      /* Red 600 (Sell/Danger) */
    --accent-rose-glow: rgba(220, 38, 38, 0.15);
    --accent-amber: #d97706;     /* Amber 600 (Warning) */
    --accent-amber-glow: rgba(217, 119, 6, 0.15);
    --accent-purple: #7c3aed;    /* Violet 600 */
    --accent-purple-glow: rgba(124, 58, 237, 0.15);

    /* Text Colors - EXTREMELY HIGH Legibility for Seniors */
    --text-main: #0f172a;        /* Slate 900 - Very deep black-blue */
    --text-secondary: #334155;   /* Slate 700 - Dark grey for subtext */
    --text-muted: #475569;       /* Slate 600 - Labels */
    --text-dim: #64748b;         /* Slate 500 - Secondary text */

    /* Typography & Senior-Friendly Radius */
    --font-heading: 'Outfit', 'Sarabun', sans-serif;
    --font-body: 'Inter', 'Sarabun', sans-serif;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base Styles & Resets
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 1.05rem; /* Senior-friendly base text sizing */
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

/* Custom Scrollbars - Highly Visible */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 5px;
    border: 2px solid var(--bg-tertiary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* ==========================================================================
   Reusable UI Components
   ========================================================================== */

/* Glass Card - Adapted to Light Theme */
.glass-card {
    background: var(--bg-secondary);
    border: 2px solid var(--card-border); /* Thicker borders */
    border-radius: var(--radius-md);
    padding: 1.75rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05); /* Soft premium shadow */
    transition: all var(--transition-normal);
}

.glass-card.interactive:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    transform: translateY(-2px);
}

/* Highly Legible Neon Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-cyan {
    background: var(--accent-cyan-glow);
    color: #0369a1; /* Darker blue for light bg */
    border: 2px solid rgba(2, 132, 199, 0.3);
}

.badge-emerald {
    background: var(--accent-emerald-glow);
    color: #047857; /* Darker green */
    border: 2px solid rgba(5, 150, 105, 0.3);
}

.badge-rose {
    background: var(--accent-rose-glow);
    color: #b91c1c; /* Darker red */
    border: 2px solid rgba(220, 38, 38, 0.3);
}

.badge-amber {
    background: var(--accent-amber-glow);
    color: #b45309; /* Darker orange */
    border: 2px solid rgba(217, 119, 6, 0.3);
}

/* Large Senior-Friendly Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: 1rem; /* Bigger font */
    font-weight: 700;
    padding: 0.9rem 1.75rem; /* Larger padding for easy click */
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--accent-cyan-glow);
}

.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px var(--accent-cyan-glow);
    transform: translateY(-1px);
}

.btn-emerald {
    background: linear-gradient(135deg, var(--accent-emerald), #047857);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.btn-emerald:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px var(--accent-emerald-glow);
    transform: translateY(-1px);
}

.btn-rose {
    background: linear-gradient(135deg, var(--accent-rose), #b91c1c);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--accent-rose-glow);
}

.btn-rose:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px var(--accent-rose-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    border: 2px solid var(--card-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-cyan);
}

.btn-icon {
    padding: 0.7rem;
    border-radius: var(--radius-sm);
}

/* Senior-Friendly Forms (Thick Borders, High Contrast) */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-label {
    font-family: var(--font-heading);
    font-size: 0.95rem; /* Larger */
    font-weight: 700;
    color: var(--text-main); /* High contrast label */
}

.form-input {
    background: #ffffff;
    border: 2.5px solid var(--card-border); /* Thicker borders */
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1.15rem; /* Large font size for easy typing */
    font-weight: 600;
    padding: 0.9rem 1.1rem; /* Thick padding */
    transition: all var(--transition-fast);
    outline: none;
    width: 100%;
}

.form-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
    background: #ffffff;
}

.form-input::placeholder {
    color: var(--text-dim);
    font-weight: normal;
}

.form-input:disabled {
    background: var(--bg-tertiary);
    opacity: 0.7;
    cursor: not-allowed;
    border-color: var(--card-border);
}

/* Premium Readable Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 2px solid var(--card-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 1rem;
}

.custom-table th {
    background: var(--bg-tertiary);
    color: var(--text-main);
    font-family: var(--font-heading);
    font-weight: 700;
    padding: 1.1rem 1.35rem;
    border-bottom: 2.5px solid var(--card-border);
}

.custom-table td {
    padding: 1.1rem 1.35rem;
    border-bottom: 1.5px solid var(--card-border);
    color: var(--text-main);
    font-weight: 500;
    transition: background-color var(--transition-fast);
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: var(--bg-tertiary);
}

/* Grid helper utilities */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Real-time Flashing Colors (Light Theme Adapt)
   ========================================================================== */
@keyframes pulse-emerald {
    0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(5, 150, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

@keyframes pulse-rose {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.pulse-up {
    animation: pulse-emerald 1.5s infinite;
}

.pulse-down {
    animation: pulse-rose 1.5s infinite;
}

/* ==========================================================================
   Print and Receipt Aesthetics (Invisible on screen)
   ========================================================================== */
.print-section {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    
    .print-section, .print-section * {
        visibility: visible;
    }
    
    .print-section {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        color: #000000 !important;
        background: #ffffff !important;
        font-family: 'Sarabun', 'Inter', sans-serif !important;
    }
}

/* thermal print styling (80mm slip) */
.thermal-slip {
    width: 80mm;
    padding: 3mm;
    margin: 0 auto;
    font-size: 12px;
    line-height: 1.5;
    color: #000;
    background: #fff;
}

.thermal-slip .header {
    text-align: center;
    margin-bottom: 4mm;
}

.thermal-slip .title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 2px;
}

.thermal-slip .divider {
    border-top: 1.5px dashed #000;
    margin: 3mm 0;
}

.thermal-slip .tx-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.thermal-slip .tx-row.total {
    font-size: 14px;
    font-weight: bold;
}

/* Slip multi-currency item table */
.thermal-slip-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2mm 0;
    font-size: 11px;
}

.thermal-slip-table th {
    border-bottom: 1.5px dashed #000;
    border-top: 1.5px dashed #000;
    padding: 1.5px 0;
    text-align: left;
    font-weight: bold;
}

.thermal-slip-table td {
    padding: 2px 0;
}

/* Full official A4 receipt styling */
.a4-receipt {
    width: 210mm;
    min-height: 297mm;
    padding: 10mm 15mm;
    margin: 0 auto;
    background: #fff;
    color: #000;
    font-size: 13px;
    box-sizing: border-box;
}

.a4-receipt .header-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8mm;
}

.a4-receipt .logo-col {
    width: 15%;
    vertical-align: middle;
}

.a4-receipt .logo-mock {
    width: 50px;
    height: 50px;
    border: 3px solid #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

.a4-receipt .company-title {
    font-size: 18px;
    font-weight: bold;
}

.a4-receipt .company-sub {
    font-size: 12px;
    color: #444;
}

.a4-receipt .doc-title-col {
    text-align: right;
    vertical-align: top;
}

.a4-receipt .doc-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.a4-receipt .meta-box {
    border: 1.5px solid #ccc;
    border-radius: 6px;
    padding: 4mm;
    margin-bottom: 6mm;
    background: #fafafa;
}

.a4-receipt .grid-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2mm 6mm;
}

.a4-receipt .item-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12mm;
}

.a4-receipt .item-table th {
    border-bottom: 2.5px solid #000;
    border-top: 1.5px solid #000;
    padding: 3mm 2mm;
    font-weight: bold;
    text-align: left;
}

.a4-receipt .item-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

.a4-receipt .item-table tr.total-row td {
    border-top: 2.5px solid #000;
    border-bottom: 2.5px solid #000;
    font-weight: bold;
    font-size: 15px;
}

.a4-receipt .footer-signs {
    display: flex;
    justify-content: space-between;
    margin-top: 10mm;
}

.a4-receipt .sign-box {
    width: 45%;
    text-align: center;
    border-top: 1.5px solid #000;
    padding-top: 2mm;
}

.a4-receipt .bot-footnote {
    font-size: 11px;
    color: #555;
    text-align: center;
    margin-top: 8mm;
    border-top: 1.5px dotted #ccc;
    padding-top: 4mm;
}

/* ==========================================================================
   A4 Daily Rate Sheet Specific Styles
   ========================================================================== */
.a4-rate-sheet {
    width: 210mm;
    height: 297mm;
    padding: 10mm 15mm;
    margin: 0 auto;
    background: #ffffff;
    color: #000000;
    box-sizing: border-box;
}

.a4-rate-sheet-header {
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 3mm;
    margin-bottom: 4mm;
}

.a4-rate-sheet-table {
    width: 100%;
    border-collapse: collapse;
}

.a4-rate-sheet-table th {
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    padding: 6px 4px;
    font-weight: bold;
    font-size: 13px;
    text-align: left;
    background: #f4f4f5;
}

.a4-rate-sheet-table td {
    border-bottom: 1px solid #ddd;
    padding: 5px 4px;
    font-size: 12px;
    font-weight: 600;
}

.a4-rate-sheet-table tr.major-currency {
    background: #fafafa;
}

.a4-rate-sheet-table tr:hover {
    background: none;
}

@media print {
    .a4-rate-sheet {
        height: 297mm !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
        overflow: hidden !important;
    }
    .a4-receipt {
        height: auto !important;
        min-height: 297mm;
        page-break-after: auto !important;
        page-break-inside: auto !important;
        overflow: visible !important;
    }
    .a4-receipt .item-table tr {
        page-break-inside: avoid !important;
    }
}
