/* ═══════════════════════════════════════════
   Stockbasetrade Admin – Shared Stylesheet
   ═══════════════════════════════════════════ */
:root {
    --sidebar-bg: #0d1b2a;
    --sidebar-hover: #162638;
    --sidebar-active: #1e3a52;
    --sidebar-width: 265px;
    --accent-blue: #4e9af1;
    --accent-teal: #26c6da;
    --accent-green: #66bb6a;
    --accent-orange: #ffa726;
    --accent-red: #ef5350;
    --topbar-h: 66px;
    --page-bg: #f0f2f5;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--page-bg);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    color: #333;
}

/* ────────────────── SIDEBAR ────────────────── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform .3s ease;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    text-decoration: none;
}
.sidebar-brand .avatar-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-brand .brand-text .brand-title {
    color: #fff;
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    line-height: 1.2;
    display: block;
}
.sidebar-brand .brand-text .brand-sub {
    color: rgba(255,255,255,.4);
    font-size: .76rem;
    letter-spacing: .8px;
    text-transform: uppercase;
    display: block;
    margin-top: 1px;
}

.nav-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: rgba(255,255,255,.28);
    padding: 18px 18px 6px;
}
.section-divider { height: 1px; background: rgba(255,255,255,.06); margin: 6px 0; }

.sidebar-nav { list-style: none; flex: 1; padding-bottom: 20px; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 0;
    color: rgba(255,255,255,.68);
    text-decoration: none;
    font-size: .97rem;
    font-weight: 500;
    transition: background .17s, color .17s;
    white-space: nowrap;
    position: relative;
}
.sidebar-nav li a:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav li a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav li a .nav-icon { width: 20px; text-align: center; font-size: .98rem; flex-shrink: 0; }
.sidebar-nav li a .badge-pill {
    margin-left: auto;
    background: rgba(255,255,255,.13);
    color: rgba(255,255,255,.8);
    font-size: .76rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
    transition: background .2s;
}
.sidebar-nav li a.active .badge-pill,
.sidebar-nav li a:hover  .badge-pill { background: var(--accent-blue); color: #fff; }

/* ────────────────── MAIN ────────────────── */
#main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ────────────────── TOPBAR ────────────────── */
#topbar {
    height: var(--topbar-h);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid #e9ecef;
    position: sticky; top: 0; z-index: 900;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    gap: 12px;
}
#topbar .page-title { font-size: 1.45rem; font-weight: 700; color: #1a2e44; white-space: nowrap; }
#topbar .topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#topbar .topbar-right .admin-email { font-size: .95rem; color: #6c757d; font-weight: 500; white-space: nowrap; }
.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #f0f2f5;
    border: none;
    display: flex; align-items: center; justify-content: center;
    color: #495057;
    font-size: 1rem;
    cursor: pointer;
    transition: background .17s;
    text-decoration: none;
}
.icon-btn:hover { background: #dee2e6; color: #1a2e44; }

/* ────────────────── CONTENT ────────────────── */
#content { padding: 30px 32px; flex: 1; }

/* ────────────────── CARDS ────────────────── */
.card-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    padding: 28px 30px;
}
.card-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.card-panel .panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a2e44;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-panel .panel-title i { color: var(--accent-blue); }

/* ────────────────── STAT CARDS ────────────────── */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    border-top: 4px solid transparent;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-card .stat-label {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.stat-card .stat-value {
    font-size: 1.95rem;
    font-weight: 700;
    color: #1a2e44;
    margin-bottom: 12px;
    line-height: 1.1;
}
.stat-card .stat-value small { font-size: .95rem; font-weight: 400; color: #6c757d; display: block; margin-top: 3px; }
.stat-card .stat-icon {
    margin-top: auto;
    align-self: flex-end;
    width: 46px; height: 46px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}
.blue-card   { border-top-color: var(--accent-blue);   } .blue-card   .stat-label { color: var(--accent-blue);   } .blue-card   .stat-icon { background: rgba(78,154,241,.12); color: var(--accent-blue);   }
.teal-card   { border-top-color: var(--accent-teal);   } .teal-card   .stat-label { color: var(--accent-teal);   } .teal-card   .stat-icon { background: rgba(38,198,218,.12); color: var(--accent-teal);   }
.green-card  { border-top-color: var(--accent-green);  } .green-card  .stat-label { color: var(--accent-green);  } .green-card  .stat-icon { background: rgba(102,187,106,.12); color: var(--accent-green);  }
.orange-card { border-top-color: var(--accent-orange); } .orange-card .stat-label { color: var(--accent-orange); } .orange-card .stat-icon { background: rgba(255,167,38,.12);  color: var(--accent-orange); }
.red-card    { border-top-color: var(--accent-red);    } .red-card    .stat-label { color: var(--accent-red);    } .red-card    .stat-icon { background: rgba(239,83,80,.12);   color: var(--accent-red);    }

/* ────────────────── TABLES ────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table thead th {
    background: #f8f9fa;
    color: #6c757d;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    padding: 13px 16px;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid #f0f2f5; transition: background .14s; }
.data-table tbody tr:hover { background: #f8f9fa; }
.data-table tbody td { padding: 13px 16px; color: #495057; vertical-align: middle; }
.data-table tbody td:first-child { color: #adb5bd; font-size: .87rem; }
.table-wrap { overflow-x: auto; }

/* ────────────────── BADGES ────────────────── */
.badge { display: inline-block; padding: 4px 11px; border-radius: 12px; font-size: .78rem; font-weight: 700; }
.badge-pending  { background: rgba(255,167,38,.15);  color: #c76600; }
.badge-approved { background: rgba(102,187,106,.15); color: #276f2c; }
.badge-rejected { background: rgba(239,83,80,.15);   color: #b71c1c; }
.badge-active   { background: rgba(102,187,106,.15); color: #276f2c; }
.badge-inactive { background: rgba(189,189,189,.2);  color: #616161; }
.badge-open     { background: rgba(78,154,241,.15);  color: #1a56b0; }
.badge-closed   { background: rgba(189,189,189,.2);  color: #616161; }
.badge-unread   { background: rgba(78,154,241,.15);  color: #1a56b0; }
.badge-read     { background: rgba(189,189,189,.2);  color: #616161; }
.badge-published{ background: rgba(102,187,106,.15); color: #276f2c; }
.badge-live     { background: rgba(239,83,80,.15);   color: #b71c1c; }
.badge-demo     { background: rgba(78,154,241,.15);  color: #1a56b0; }

/* ────────────────── ACTION BUTTONS ────────────────── */
.btn-action {
    border: none;
    border-radius: 7px;
    padding: 7px 16px;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .17s, transform .12s, box-shadow .12s;
    display: inline-flex; align-items: center; gap: 5px;
    text-decoration: none;
    letter-spacing: .2px;
    white-space: nowrap;
}
.btn-action:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.13); }
/* Give table action cells automatic gap between adjacent buttons */
td .btn-action + .btn-action { margin-left: 6px; }
.btn-approve { background: #2e7d32;           color: #fff; }
.btn-reject  { background: #c62828;           color: #fff; }
.btn-view    { background: #1565c0;           color: #fff; }
.btn-delete  { background: #c62828;           color: #fff; }
.btn-edit    { background: #e65100;           color: #fff; }
.btn-primary-sm { background: var(--accent-blue); color: #fff; }

/* ────────────────── SEARCH / FILTER BAR ────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: .95rem;
    outline: none;
    transition: border-color .18s;
    background: #fff;
    color: #333;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent-blue); }
.filter-bar input { min-width: 220px; }

/* ────────────────── MODAL ────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 34px 36px;
    width: 100%;
    max-width: 580px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-box h3 { font-size: 1.25rem; font-weight: 700; color: #1a2e44; margin-bottom: 22px; }
.modal-close {
    position: absolute; top: 18px; right: 22px;
    background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #adb5bd;
    line-height: 1;
}
.modal-close:hover { color: #495057; }
.modal-field { margin-bottom: 18px; }
.modal-field label { font-size: .92rem; font-weight: 600; color: #495057; display: block; margin-bottom: 5px; }
.modal-field input, .modal-field select, .modal-field textarea {
    width: 100%; border: 1px solid #dee2e6; border-radius: 8px;
    padding: 10px 14px; font-size: .97rem; outline: none;
    transition: border-color .18s;
}
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color: var(--accent-blue); }
.modal-field textarea { resize: vertical; min-height: 90px; }
.modal-row { display: flex; gap: 12px; }
.modal-row .modal-field { flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
.btn-modal-save {
    background: var(--accent-blue); color: #fff; border: none; border-radius: 8px;
    padding: 11px 28px; font-size: .97rem; font-weight: 700; cursor: pointer;
    transition: background .17s;
}
.btn-modal-save:hover { background: #3a83d8; }
.btn-modal-cancel {
    background: #f0f2f5; color: #6c757d; border: none; border-radius: 8px;
    padding: 11px 22px; font-size: .97rem; font-weight: 600; cursor: pointer;
}

/* ────────────────── TOAST ────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: #1a2e44; color: #fff; border-radius: 8px; padding: 14px 22px;
    font-size: .97rem; font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
    display: flex; align-items: center; gap: 10px;
    animation: slideIn .25s ease;
    min-width: 280px;
}
.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error   { border-left: 4px solid var(--accent-red);   }
.toast.info    { border-left: 4px solid var(--accent-blue);  }
@keyframes slideIn { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }

/* ────────────────── EXPIRY BANNER ────────────────── */
.expiry-banner {
    background: #fff;
    border-radius: 10px;
    padding: 15px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    border-left: 4px solid var(--accent-blue);
}
.expiry-banner .expiry-text { font-size: 1.05rem; font-weight: 600; color: #1a2e44; }
.expiry-banner .expiry-text span { color: #6c757d; font-weight: 400; }
.btn-report {
    background: var(--accent-blue); color: #fff; border: none; border-radius: 7px;
    padding: 10px 22px; font-size: .97rem; font-weight: 700; cursor: pointer;
    transition: background .17s, transform .12s;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.btn-report:hover { background: #3a83d8; transform: translateY(-1px); }

/* ────────────────── EMPTY STATE ────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: #adb5bd; }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 14px; }
.empty-state p { font-size: 1.05rem; }

/* ────────────────── PROFIT COLORS ────────────────── */
.profit-pos { color: #276f2c; font-weight: 600; }
.profit-neg { color: #b71c1c; font-weight: 600; }

/* ────────────────── PAGINATION ────────────────── */
.pagination-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; font-size: .95rem; color: #6c757d; }
.pagination-bar button {
    border: 1px solid #dee2e6; background: #fff; border-radius: 6px;
    padding: 6px 13px; cursor: pointer; color: #495057; font-size: .92rem;
    transition: background .15s;
}
.pagination-bar button:hover:not(:disabled) { background: #f0f2f5; }
.pagination-bar button:disabled { opacity: .4; cursor: default; }
.pagination-bar button.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* ────────────────── RESPONSIVE ────────────────── */

/* Sidebar overlay for mobile tap-to-close */
#sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
}
#sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main { margin-left: 0; }
    #topbar { padding: 0 16px; gap: 8px; }
    #content { padding: 16px; }
    .filter-bar input { min-width: 140px; }
    .modal-box { padding: 28px 22px; }
    .stat-card .stat-value { font-size: 1.65rem; }
    .btn-action { padding: 6px 13px; font-size: .85rem; }
    td .btn-action + .btn-action { margin-left: 4px; }
    .pagination-bar { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 576px) {
    #content { padding: 12px; }
    #topbar { padding: 0 12px; }
    #topbar .page-title { font-size: 1.1rem; }
    #topbar .topbar-right .admin-email { display: none; }
    .card-panel { padding: 18px 16px; }
    .card-panel .panel-header { margin-bottom: 16px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input,
    .filter-bar select { min-width: 100%; width: 100%; }
    .modal-box { padding: 22px 16px; }
    .modal-row { flex-direction: column; }
    .modal-actions { flex-wrap: wrap; }
    .btn-modal-save,
    .btn-modal-cancel { width: 100%; text-align: center; justify-content: center; }
    .stat-card { padding: 16px 15px; }
    .stat-card .stat-value { font-size: 1.45rem; }
    .data-table thead th { padding: 10px 10px; font-size: .75rem; }
    .data-table tbody td { padding: 10px 10px; font-size: .88rem; }
    .btn-action { padding: 5px 10px; font-size: .82rem; }
    td .btn-action + .btn-action { margin-left: 3px; }
    .toast { min-width: 240px; font-size: .9rem; }
    .expiry-banner { flex-direction: column; align-items: flex-start; }
    .pagination-bar button { padding: 5px 10px; font-size: .85rem; }
}

@media (max-width: 480px) {
    #content { padding: 10px 8px; }
    #topbar { padding: 0 10px; }
    #topbar .page-title { font-size: 1rem; }
    .card-panel { padding: 14px 12px; border-radius: 10px; }
    .modal-box { padding: 18px 12px; border-radius: 10px; }
    .modal-box h3 { font-size: 1.1rem; }
    .data-table thead th { padding: 9px 8px; font-size: .73rem; letter-spacing: .4px; }
    .data-table tbody td { padding: 9px 8px; font-size: .85rem; }
    .btn-action { padding: 5px 9px; font-size: .80rem; border-radius: 5px; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
    .btn-report { font-size: .88rem; padding: 8px 14px; }
    .badge { padding: 3px 8px; font-size: .74rem; }
}
