/* ═══════════════════════════════════════════════════
   GestVente Pro — Stylesheet
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg0: #0c0e14;
    --bg1: #11131c;
    --bg2: #181b28;
    --bg3: #1e2235;
    --bg4: #262a40;
    --bgH: #2c3050;
    --brd: #282d45;
    --t1: #eae8e3;
    --t2: #8d91a8;
    --t3: #585d75;
    --acc: #c8a455;
    --accL: #dbc272;
    --accD: #a88b3a;
    --accBg: rgba(200,164,85,.08);
    --ok: #4ade80;
    --err: #f87171;
    --inf: #60a5fa;
    --wrn: #fbbf24;
    --r: 10px;
    --rl: 16px;
    --sh: 0 4px 24px rgba(0,0,0,.35);
    --ff: 'DM Sans', -apple-system, sans-serif;
    --fd: 'Playfair Display', Georgia, serif;
    --tr: .2s cubic-bezier(.4,0,.2,1);
}

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

body {
    font-family: var(--ff);
    background: var(--bg0);
    color: var(--t1);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 3px; }

a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--accL); }

/* ─── Layout ─── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 240px;
    background: var(--bg1);
    border-right: 1px solid var(--brd);
    display: flex;
    flex-direction: column;
    transition: width .25s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed { width: 58px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer-info,
.sidebar.collapsed .brand-name { display: none; }

.sidebar-brand {
    padding: 16px 14px;
    border-bottom: 1px solid var(--brd);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.brand-icon {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--acc), var(--accD));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #1a1a2e;
    font-weight: 700;
    font-family: var(--fd);
    font-size: .95rem;
    flex-shrink: 0;
}
.brand-name { font-family: var(--fd); font-weight: 700; font-size: .95rem; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 10px 6px; overflow-y: auto; }
.sidebar-nav .divider { height: 1px; background: var(--brd); margin: 6px 8px; }

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    background: transparent;
    color: var(--t2);
    border: 1px solid transparent;
    margin-bottom: 1px;
    font-weight: 400;
    font-size: .84rem;
    cursor: pointer;
    transition: all var(--tr);
    font-family: var(--ff);
}
.nav-item:hover { background: var(--bgH); color: var(--t1); }
.nav-item.active {
    background: var(--accBg);
    color: var(--acc);
    border-color: rgba(200,164,85,.15);
    font-weight: 600;
}
.nav-item svg { flex-shrink: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; }

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--brd);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-footer .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accBg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .72rem;
    color: var(--acc);
    flex-shrink: 0;
}

.main-content {
    flex: 1;
    overflow: auto;
    padding: 28px;
    background: var(--bg0);
}
.main-content .container { max-width: 1140px; margin: 0 auto; }

/* ─── Forms ─── */
input, select, textarea {
    font-family: var(--ff);
    font-size: .88rem;
    color: var(--t1);
    background: var(--bg3);
    border: 1.5px solid var(--brd);
    border-radius: var(--r);
    padding: 10px 14px;
    outline: none;
    transition: border var(--tr), box-shadow var(--tr);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--acc);
    box-shadow: 0 0 0 3px var(--accBg);
}
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238d91a8' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
select option { background: var(--bg3); color: var(--t1); }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--t2);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Buttons ─── */
button { font-family: var(--ff); font-weight: 600; cursor: pointer; border: none; border-radius: var(--r); transition: all var(--tr); display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: linear-gradient(135deg, var(--acc), var(--accD)); color: #1a1a2e; padding: 10px 20px; font-size: .88rem; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,164,85,.3); }
.btn-secondary { background: var(--bgH); color: var(--t1); padding: 8px 16px; font-size: .84rem; border: 1px solid var(--brd); }
.btn-secondary:hover { border-color: var(--acc); color: var(--acc); }
.btn-danger { background: rgba(248,113,113,.1); color: var(--err); padding: 7px 12px; font-size: .8rem; }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-icon { background: transparent; color: var(--t2); padding: 6px; border-radius: 8px; }
.btn-icon:hover { background: var(--bgH); color: var(--acc); }

/* ─── Badges ─── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .73rem; font-weight: 600; }
.badge-ok { background: rgba(74,222,128,.1); color: var(--ok); }
.badge-wrn { background: rgba(251,191,36,.1); color: var(--wrn); }
.badge-inf { background: rgba(96,165,250,.1); color: var(--inf); }
.badge-acc { background: var(--accBg); color: var(--acc); }
.badge-err { background: rgba(248,113,113,.1); color: var(--err); }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; border-radius: var(--rl); border: 1px solid var(--brd); background: var(--bg2); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; padding: 12px 16px; font-size: .73rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--t3); border-bottom: 1px solid var(--brd); }
td { padding: 11px 16px; font-size: .86rem; border-bottom: 1px solid rgba(40,45,69,.5); vertical-align: middle; }
tr:hover td { background: rgba(200,164,85,.02); }

/* ─── Cards ─── */
.card { background: var(--bg2); border: 1px solid var(--brd); border-radius: var(--rl); padding: 22px; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; border-radius: 0 4px 4px 0; }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--brd); }
.tab { padding: 10px 18px; font-size: .85rem; font-weight: 500; color: var(--t2); background: transparent; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all var(--tr); font-family: var(--ff); }
.tab:hover { color: var(--t1); }
.tab.active { color: var(--acc); border-bottom-color: var(--acc); font-weight: 600; }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: fadeIn .15s;
}
.modal-box {
    background: var(--bg2);
    border: 1px solid var(--brd);
    border-radius: var(--rl);
    width: 92%; max-width: 620px; max-height: 86vh;
    overflow-y: auto;
    box-shadow: var(--sh);
    animation: scaleIn .2s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--brd); }
.modal-header h3 { font-family: var(--fd); font-size: 1.15rem; }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--brd); }

/* ─── Page header ─── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-family: var(--fd); font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.page-header .subtitle { color: var(--t2); font-size: .88rem; margin-top: 3px; }

/* ─── Search ─── */
.search-box { position: relative; margin-bottom: 18px; max-width: 340px; }
.search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--t3); }
.search-box input { padding-left: 38px; }

/* ─── Payment buttons ─── */
.payment-btn {
    flex: 1; min-width: 100px; padding: 13px;
    background: var(--bg3); border: 2px solid var(--brd);
    border-radius: var(--r); text-align: center;
    font-weight: 600; color: var(--t1); cursor: pointer;
    transition: all var(--tr); font-family: var(--ff);
}
.payment-btn:hover, .payment-btn.active { border-color: var(--acc); background: var(--accBg); color: var(--acc); }

/* ─── Stats grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--bg2); border: 1px solid var(--brd); border-radius: var(--rl); padding: 20px; position: relative; }
.stat-label { font-size: .73rem; color: var(--t2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.stat-value { font-size: 1.35rem; font-family: var(--fd); font-weight: 700; }

/* ─── Products grid ─── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.product-card {
    background: var(--bg2); border: 1px solid var(--brd);
    border-radius: var(--r); padding: 12px; cursor: pointer;
    transition: all var(--tr);
}
.product-card:hover { border-color: var(--acc); transform: translateY(-2px); }
.product-card img { width: 100%; height: 65px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.product-card .placeholder { width: 100%; height: 65px; background: var(--bg3); border-radius: 6px; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; color: var(--t3); }

/* ─── Cart ─── */
.cart-panel {
    background: var(--bg2); border: 1px solid var(--brd);
    border-radius: var(--rl); padding: 18px;
    position: sticky; top: 14px;
}

/* ─── Login ─── */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bg0), var(--bg1));
}
.login-box {
    background: var(--bg2);
    border: 1px solid var(--brd);
    border-radius: var(--rl);
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--sh);
}
.login-box .brand { text-align: center; margin-bottom: 32px; }
.login-box .brand-icon-lg {
    width: 56px; height: 56px; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--acc), var(--accD));
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #1a1a2e; font-weight: 700; font-family: var(--fd); font-size: 1.5rem;
}
.login-box h2 { font-family: var(--fd); font-size: 1.4rem; margin-bottom: 4px; }
.login-box .login-sub { color: var(--t2); font-size: .88rem; }
.login-box .error-msg { color: var(--err); font-size: .84rem; margin-bottom: 12px; text-align: center; }

/* ─── Chart bars ─── */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; padding: 10px 0; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar-val { font-size: .7rem; color: var(--t2); font-weight: 600; }
.chart-bar { width: 100%; max-width: 40px; border-radius: 4px 4px 0 0; transition: height .4s ease; min-height: 4px; }
.chart-bar-label { font-size: .66rem; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; text-align: center; }

/* ─── Invoice preview ─── */
.invoice-preview {
    background: #fff; color: #1a1a2e;
    border-radius: 10px; padding: 22px;
    font-size: .82rem;
}

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
.anim-fade { animation: fadeIn .3s ease-out both; }

/* ─── Toast ─── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 14px 22px; border-radius: var(--r);
    font-weight: 600; font-size: .88rem;
    z-index: 2000;
    animation: fadeIn .2s;
    box-shadow: var(--sh);
}
.toast-ok { background: rgba(74,222,128,.15); color: var(--ok); border: 1px solid rgba(74,222,128,.3); }
.toast-err { background: rgba(248,113,113,.15); color: var(--err); border: 1px solid rgba(248,113,113,.3); }

/* ─── Print ─── */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

/* ─── Loading ─── */
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--brd);
    border-top-color: var(--acc);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.loading-page {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; flex-direction: column; gap: 14px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar { width: 58px !important; }
    .sidebar .nav-label, .sidebar .sidebar-footer-info, .sidebar .brand-name { display: none !important; }
    .sidebar .nav-item { justify-content: center; padding: 9px 0; }
    .main-content { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
