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

/* ─── Design tokens ─────────────────────────────────────── */
:root {
    --brand:          #1d4ed8;
    --brand-hover:    #1e40af;
    --brand-light:    #eff6ff;
    --success:        #059669;
    --success-light:  #d1fae5;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --danger:         #dc2626;
    --danger-light:   #fee2e2;
    --info:           #0284c7;
    --info-light:     #e0f2fe;
    --bg:             #f1f5f9;
    --white:          #ffffff;
    --text:           #0f172a;
    --text-muted:     #64748b;
    --border:         #e2e8f0;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --shadow-lg:      0 20px 25px rgba(0,0,0,.10), 0 8px 10px rgba(0,0,0,.06);
    --radius-sm:      .375rem;
    --radius:         .5rem;
    --radius-lg:      .75rem;
    --radius-xl:      1rem;
    --transition:     all .2s ease;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: .9375rem;
}

/* ─── Screens ────────────────────────────────────────────── */
.screen { display: none !important; }
.screen.active { display: block !important; }

/* ─── Login ──────────────────────────────────────────────── */
#loginScreen {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #0ea5e9 100%);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

#loginScreen.active {
    display: flex !important;
}

.login-container {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 56px;
    height: 56px;
    background: var(--brand-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--brand);
    font-size: 1.5rem;
}

.login-header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .25rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: .875rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ─── Navbar ─────────────────────────────────────────────── */
.navbar {
    background: var(--white);
    height: 64px;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.navbar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--brand);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: .9rem;
}

.navbar-brand h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
}

.navbar-brand span {
    font-size: .8125rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: .25rem;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-badge {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .375rem .75rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--text-muted);
}

.admin-badge i { color: var(--brand); }

#adminName {
    font-weight: 600;
    color: var(--text);
}

/* ─── Container ──────────────────────────────────────────── */
.container {
    max-width: 1440px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.75rem;
    border-bottom: 2px solid var(--border);
    background: var(--white);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0 1rem;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    background: none;
    border: none;
    padding: .875rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.tab-btn .badge {
    background: var(--danger);
    color: white;
    border-radius: 9999px;
    padding: .125rem .4375rem;
    font-size: .6875rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.tab-btn:hover { color: var(--brand); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.tab-content { display: none; animation: fadeIn .25s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Section Header ─────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.section-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
}

/* ─── Bulk Actions ───────────────────────────────────────── */
.bulk-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── Form Elements ──────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .375rem;
}

.form-group label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="time"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    padding: .625rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--brand);
}

.form-group label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: .625rem;
    cursor: pointer;
    font-weight: 400;
}

.form-group small { color: var(--text-muted); font-size: .8125rem; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-group.full-width { grid-column: 1 / -1; }

/* ─── Settings ───────────────────────────────────────────── */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.settings-section h4 {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: .625rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
    padding: .5625rem 1.125rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .4375rem;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); box-shadow: 0 2px 8px rgba(29,78,216,.35); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; box-shadow: 0 2px 8px rgba(5,150,105,.35); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #b45309; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover:not(:disabled) { background: #0369a1; }

.btn-secondary { background: #64748b; color: white; }
.btn-secondary:hover:not(:disabled) { background: #475569; }

.btn-outline {
    background: white;
    color: var(--brand);
    border: 1.5px solid var(--brand);
}
.btn-outline:hover { background: var(--brand); color: white; }

.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Table ──────────────────────────────────────────────── */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table thead { background: #f8fafc; }

.data-table th {
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

.data-table input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--brand);
}

/* ─── Status Badges ──────────────────────────────────────── */
.status-badge {
    padding: .25rem .625rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .3125rem;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-active    { background: var(--success-light); color: #065f46; }
.status-inactive  { background: var(--danger-light);  color: #991b1b; }
.status-pending   { background: var(--warning-light); color: #78350f; }
.sync-enabled     { background: var(--info-light);    color: #075985; }
.sync-disabled    { background: var(--warning-light); color: #78350f; }
.env-sandbox      { background: var(--warning-light); color: #78350f; }
.env-production   { background: var(--success-light); color: #065f46; }

/* ─── Messages ───────────────────────────────────────────── */
.error-message {
    display: none;
    padding: .75rem 1rem;
    background: var(--danger-light);
    color: #991b1b;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--danger);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.error-message.show { display: flex; gap: .5rem; align-items: center; }

.success-message {
    display: none;
    padding: .75rem 1rem;
    background: var(--success-light);
    color: #065f46;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--success);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.success-message.show { display: flex; gap: .5rem; align-items: center; }

.loading {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: .9375rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--border);
    display: block;
}

.empty-state p { margin: .25rem 0; }

.empty-state a { color: var(--brand); text-decoration: none; font-weight: 500; }
.empty-state a:hover { text-decoration: underline; }

/* ─── Info box ───────────────────────────────────────────── */
.info-box {
    background: var(--info-light);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--info);
    margin-bottom: 1.5rem;
}

.info-box h4 {
    margin-top: 0;
    margin-bottom: .5rem;
    color: #075985;
    font-size: .9375rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.info-box ul { margin: .5rem 0; padding-left: 1.25rem; }
.info-box li { margin: .25rem 0; color: #0c4a6e; font-size: .875rem; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(2px);
}

.modal.active { display: flex !important; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.97) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 1;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.125rem;
    transition: var(--transition);
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ─── Card ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

/* ─── Register page ──────────────────────────────────────── */
.register-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #0ea5e9 100%);
    padding: 2rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.register-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    padding: 2.5rem;
    margin: auto;
}

.register-header {
    text-align: center;
    margin-bottom: 2rem;
}

.register-logo {
    width: 56px;
    height: 56px;
    background: var(--brand-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--brand);
    font-size: 1.5rem;
}

.register-header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .25rem;
}

.register-header p { color: var(--text-muted); font-size: .9375rem; }

/* ─── Rates page ─────────────────────────────────────────── */
.rates-page {
    min-height: 100vh;
    background: var(--bg);
    padding: 1.5rem;
}

.rates-container {
    max-width: 1100px;
    margin: 0 auto;
}

.rates-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #0ea5e9 100%);
    color: white;
    padding: 2rem 2.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.rates-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .25rem;
}

.rates-header p { opacity: .85; font-size: .875rem; }

.rates-search-card {
    background: var(--white);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.button-group {
    display: flex;
    gap: .625rem;
    flex-wrap: wrap;
}

.results-section {
    background: var(--white);
    padding: 1.5rem 2rem;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
    color: var(--text-muted);
    gap: 1rem;
    flex-wrap: wrap;
}

.results-header strong { color: var(--text); font-size: 1rem; }

.rates-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.rates-table thead { background: #f8fafc; }
.rates-table th {
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
.rates-table td { padding: 1rem; border-bottom: 1px solid var(--border); }
.rates-table tbody tr:hover { background: #f8fafc; }
.rates-table tbody tr:last-child td { border-bottom: none; }

.currency-code  { font-weight: 700; color: var(--brand); font-size: 1rem; }
.currency-name  { color: var(--text-muted); font-size: .8125rem; }
.rate-value     { font-weight: 600; font-size: 1rem; color: var(--text); }

.unit-badge {
    display: inline-block;
    padding: .1875rem .5rem;
    background: var(--warning-light);
    color: var(--warning);
    border-radius: 9999px;
    font-size: .6875rem;
    font-weight: 600;
    margin-left: .375rem;
}

.expand-btn {
    background: var(--brand-light);
    color: var(--brand);
    border: none;
    padding: .375rem .75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    transition: var(--transition);
    font-family: inherit;
}
.expand-btn:hover { background: var(--brand); color: white; }

.other-rates {
    display: none;
    margin-top: .75rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--brand);
}
.other-rates.show { display: block; }

.other-rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .5rem;
    margin-top: .625rem;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    padding: .5rem .625rem;
    background: white;
    border-radius: var(--radius-sm);
    font-size: .8125rem;
    border: 1px solid var(--border);
}
.rate-item-code  { font-weight: 700; color: var(--brand); }
.rate-item-value { font-weight: 600; color: var(--text); }

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.no-results i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    opacity: .35;
}

.error {
    background: var(--danger-light);
    color: #991b1b;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--danger);
    margin: 1rem 0;
    font-size: .875rem;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .navbar-brand h2 { font-size: .9375rem; }
    .container { padding: 0 1rem; margin: 1rem auto; }
    .tabs { overflow-x: auto; padding: 0 .5rem; }
    .tab-btn { padding: .75rem .875rem; font-size: .8125rem; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .bulk-actions { width: 100%; }
    .data-table { font-size: .8125rem; }
    .data-table th, .data-table td { padding: .625rem .75rem; }
    .modal-content { max-width: 100%; border-radius: var(--radius); }
    .register-container { padding: 1.5rem; }
    .rates-header { padding: 1.5rem; }
    .rates-search-card, .results-section { padding: 1rem; }
    .search-form { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
