/* Google Fonts moved to HTML head for Performance */

:root {
    /* Main Background: Subtle off-white/grey fallback */
    --bg-main: #F8FAFC;

    /* Surfaces: Soft glass panels */
    --surface-bg: rgba(255, 255, 255, 0.85);
    --surface-border: rgba(255, 255, 255, 0.4);
    --surface-shadow: 0 10px 40px rgba(15, 23, 42, 0.1), 0 2px 10px rgba(15, 23, 42, 0.05);

    /* Text Colors */
    --text-primary: #020617;
    --text-secondary: #0F172A;
    --text-muted: #1E293B;

    /* Accessibility Fix: More opaque background for contrast */
    --surface-bg: rgba(255, 255, 255, 0.98);
    --surface-border: rgba(0, 0, 0, 0.1);

    /* Brand Accents */
    --accent-gold: #f4b752;
    --accent-teal: #1F8E8A;

    /* Structure */
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-main);
    background-image: url('images/background-optimized.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Base Panel / GLASSMORPHISM (Default) */
.glass-panel {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* -------------------------------------------------------------------------- */
/* DISPLAY BOARD SPECIFIC (index.php)                                         */
/* -------------------------------------------------------------------------- */

.display-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 3rem;
    max-width: 1920px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 7rem;
    /* Space for ticker */
}

/* Header */
.header-glass {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2.5rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 1rem;
    z-index: 50;
}

.logo-container img {
    height: 7rem;
    width: auto;
    object-fit: contain;
    max-width: 250px;
}

.zoom-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(8px);
}

.zoom-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
    border-radius: 6px;
}

.zoom-btn-lg {
    font-size: 1.8rem;
}

.zoom-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.1);
}


.zoom-separator {
    width: 1px;
    height: 20px;
    background: var(--surface-border);
}

.clock-container {
    display: flex;
    gap: 3em;
    font-size: 1.8em;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: none;
}

.clock-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Right-align text for cleaner look */
}

.clock-label {
    font-size: 0.45em;
    /* roughly 0.85rem / 1.8rem */
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    margin-bottom: 0.2em;
    font-weight: 600;
}

/* MODERN TABLE LAYOUT */
.table-container {
    width: 100%;
    margin-bottom: 1rem;
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    background: var(--surface-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.rates-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    min-width: 600px;
}

.rates-table thead {
    background: rgba(255, 255, 255, 0.6);
    /* Soften header */
    border-bottom: 2px solid var(--surface-border);
}

.rates-table th {
    padding: 1.2em;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.th-currency {
    text-align: left;
    padding-left: 3.5rem !important;
}

.th-achat {
    color: var(--accent-teal);
}

.th-vente {
    color: var(--accent-gold);
}

.rates-table tbody tr {
    border-bottom: 1px solid var(--surface-border);
    transition: background 0.2s;
}

.rates-table tbody tr:hover {
    background: #F8FAFC;
    /* Slate 50 row hover */
}

.rates-table tbody tr:last-child {
    border-bottom: none;
}

.rates-table td {
    padding: 0.8em 1em;
    /* Breathey padding */
    vertical-align: middle;
}

.td-currency {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-left: 3.5rem !important;
}

.td-currency img {
    width: 2.8em;
    height: 2.8em;
    object-fit: cover;
    border: 1px solid var(--surface-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.currency-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.currency-info .code {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.currency-info .name {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 400;
}

.td-achat,
.td-vente {
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: -0.03em;
    /* Tighter numbers look cleaner */
}

/* Empty Values (Em-Dashes) */
.rate-empty {
    color: var(--text-muted);
    font-weight: 400;
}

/* BRANCH ADDRESS FOOTER */
.branch-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 3rem;
    margin: 2rem;
    max-width: 100%;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.branch-details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    font-size: 1em;
    color: var(--text-secondary);
}

.branch-details strong {
    color: var(--text-primary);
    font-weight: 600;
}

.branch-details span:not(:last-child)::after {
    content: "•";
    margin-left: 1rem;
    color: var(--surface-border);
}

.branch-contact {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.5);
    /* Semi-transparent inner pill */
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.phone-label {
    color: var(--text-primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.1em;
}

.phone-number {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

/* Continuous CSS Ticker (White Frosted Glass) */
.ticker-wrap {
    width: 100%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.85);
    /* Light glassmorphism - slightly reduced for performance if needed */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 0;
    border-top: 1px solid var(--surface-border);
    transform: translateZ(0);
    /* Force layer */
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.03);
}

.ticker {
    display: flex;
    width: max-content;
    animation: ticker 25s linear infinite;
    gap: 0;
    /* Hardware acceleration hints */
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
    /* Forced to 0 to prevent math drift; spacing handled inside ticker-content */
}

.ticker-content {
    display: flex;
    gap: 3rem;
    padding-right: 3rem;
}

.ticker:hover {
    animation-play-state: paused;
}

.ticker-spacer {
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ticker-spacer img {
    height: 3.5rem;
    object-fit: contain;
}

@keyframes ticker {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

.ticker-item {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    font-size: 1.1em;
    font-weight: 600;
    background: #FFFFFF;
    /* Opaque background is faster to render */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    will-change: transform;
    backface-visibility: hidden;
}

.ticker-currency-wrap {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(248, 250, 252, 0.9);
    padding: 0.4rem 1.2rem;
    border-right: 1px solid var(--surface-border);
    border-radius: 8px 0 0 8px;
}

.ticker-flag {
    width: 1.6em;
    height: 1.6em;
    object-fit: cover;
    border: 1px solid var(--surface-border);
}

.ticker-rate {
    padding: 0.3em 0.8em;
    display: flex;
    align-items: center;
    font-size: 0.95em;
    font-weight: 700;
    border-radius: 6px;
    margin: 0.4em 0.6em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ticker-buy {
    background: #1F8E8A;
    /* CashPlus Teal */
    color: #FFFFFF;
}

.ticker-sell {
    background: linear-gradient(135deg, #EE7E27, #F4B752);
    /* CashPlus Gold */
    color: #FFFFFF;
}


/* -------------------------------------------------------------------------- */
/* ADMIN FORM SPECIFIC (admin.php)                                            */
/* -------------------------------------------------------------------------- */

.admin-container {
    max-width: 80%;
    margin: 2rem auto 4rem;
    padding: 1rem 2rem;
}

.admin-header {
    margin-bottom: 3rem;
}

.admin-header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.currency-input-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface-bg);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    border: 1px solid var(--surface-border);
    margin-bottom: 1.2rem;
    gap: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.currency-main-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.currency-input-group:focus-within {
    border-color: var(--accent-teal);
    box-shadow: 0 4px 12px rgba(31, 142, 138, 0.1);
}

.input-flag-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 110px;
    flex-shrink: 0;
}

.input-flag-wrap img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border: 1px solid var(--surface-border);
}

.input-flag-wrap span {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.inputs-wrap {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.input-field {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.input-field label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.input-field input {
    width: 100%;
    background: #FFFFFF;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all 0.2s;
    color: var(--text-primary);
}

/* Remove arrows from number inputs */
.input-field input[type="number"]::-webkit-inner-spin-button,
.input-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.save-btn-container {
    display: none;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--surface-border);
    text-align: center;
}

.btn-clean-save {
    background: transparent;
    border: 1px solid var(--accent-teal);
    color: var(--accent-teal);
    border-radius: 6px;
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}

.btn-clean-save:hover {
    background: var(--accent-teal);
    color: white;
    box-shadow: 0 4px 12px rgba(31, 142, 138, 0.2);
    transform: translateY(-2px);
}

.input-field input:focus {
    background: #FFFFFF;
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(31, 142, 138, 0.15);
}

.btn-submit {
    width: 100%;
    background: var(--text-primary);
    /* Slate Navy */
    color: white;
    border: none;
    padding: 1.2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    margin-top: 2rem;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-submit:hover {
    background: #000000;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.btn-submit:active {
    transform: translateY(0);
}

/* PIN OVERLAY STYLES */
.pin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(1, 2, 3, 0.82);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
}

.pin-modal {
    background: #FFFFFF;
    border: 1px solid var(--surface-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-lg);
    padding: 3.5rem 4rem;
    text-align: center;
    width: 90%;
    max-width: 480px;
}

.pin-header {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

.pin-subtext {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

.pin-inputs {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.pin-box {
    width: 60px;
    height: 75px;
    padding: 0;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--surface-border);
    border-radius: 12px;
    background: #F8FAFC;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.pin-box:focus {
    border-color: var(--accent-teal);
    box-shadow: 0 4px 15px rgba(31, 142, 138, 0.2);
    transform: translateY(-2px);
}

.pin-error-msg {
    color: #cc0000;
    font-size: 0.95rem;
    min-height: 24px;
    margin-bottom: 2rem;
    font-weight: 500;
}

.pin-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    min-width: 130px;
}

.btn-cancel:hover {
    background: rgba(0, 0, 0, 0.03);
}

.btn-enter {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    margin: 0;
    min-width: 130px;
}

/* Responsive */
@media (max-width: 1200px) {
    .display-board {
        padding: 1rem 1.5rem;
    }

    .clock-container {
        gap: 1.5rem;
        font-size: 1.4em;
    }
}

@media (max-width: 1024px) {
    .display-board {
        padding: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .header-glass {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding: 1.5rem;
    }

    .logo-container img {
        height: 5rem;
    }

    .clock-item {
        align-items: center;
    }

    .table-container {
        margin: 0 -1.5rem;
        width: calc(100% + 3rem);
        border-radius: 0;
    }
}

@media (max-width: 600px) {
    .display-board {
        padding: 0.8rem;
    }

    .logo-container img {
        height: 4rem;
    }

    .clock-container {
        gap: 1rem;
        font-size: 1.1em;
    }

    .td-achat,
    .td-vente {
        font-size: 1.4rem;
    }

    .branch-info {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem;
        text-align: center;
    }

    .branch-details {
        justify-content: center;
        font-size: 0.9rem;
    }
}

/* -------------------------------------------------------------------------- */
/* ADMIN TABS & DESIGN HUB                                                    */
/* -------------------------------------------------------------------------- */
/* ADMIN UI ENHANCEMENTS */
.admin-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 3rem;
}

.admin-header {
    text-align: center;
    margin-bottom: 3rem;
}

.admin-logo {
    height: 80px;
    margin-bottom: 1.5rem;
}

.admin-title-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.btn-logout {
    color: #ff4d4d;
    text-decoration: none;
    border: 1px solid #ff4d4d;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 77, 77, 0.1);
    transform: translateY(-1px);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-teal);
    border-bottom-color: var(--accent-teal);
}

.theme-card {
    cursor: pointer;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius-md);
    transition: all 0.2s;
}

.theme-card:hover {
    background: rgba(0, 0, 0, 0.02);
}

.theme-card.active {
    border-color: var(--accent-teal);
    background: rgba(31, 142, 138, 0.05);
}

/* THEME VARIANTS (applied to body class) */
body.theme-light {
    background-color: #F8FAFC;
    background-image:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 40px 40px;
    background-position: 0 0, 0 20px, 20px 20px, 20px 0;
}

body.theme-light .glass-panel {
    background: #FFFFFF;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #E2E8F0;
}

body.theme-light .zoom-controls {
    background: #FFFFFF;
    border-color: #E2E8F0;
}

body.theme-light .ticker-wrap {
    background: #FFFFFF;
    border-top: 2px solid #F1F5F9;
}

body.theme-dark {
    background-color: #020617;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --surface-bg: #1E293B;
    --surface-border: rgba(51, 65, 85, 0.5);
    color: var(--text-primary);
}

body.theme-dark .glass-panel {
    background: #0F172A;
    border-color: #1E293B;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

body.theme-dark .zoom-controls {
    background: rgba(30, 41, 59, 0.7);
    border-color: #334155;
}

body.theme-dark .zoom-btn {
    color: #F8FAFC;
}

body.theme-dark .zoom-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.theme-dark .ticker-wrap {
    background: #020617;
    border-top: 1px solid #1E293B;
}

body.theme-dark .rates-table thead {
    background: #1E293B;
}

body.theme-dark .rates-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .rates-table tbody tr:hover .name {
    color: #FFFFFF;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-bg);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 600;
    z-index: 10000;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(10px);
}

.toast-notification.show {
    bottom: 40px;
}