/* ============================================================
   deevas.css  |  Deevas Bangles Management System
   Modern rose-gold & deep-plum palette | PHP 8.0 revamp
   ============================================================ */

/* ---- CSS VARIABLES ---- */
:root {
    --primary:       #7c3f6e;   /* deep plum */
    --primary-light: #a0537f;
    --primary-dark:  #5a2d50;
    --accent:        #d4916b;   /* rose-gold */
    --accent-light:  #f0c8a8;
    --success:       #28a745;
    --warning:       #ffc107;
    --danger:        #dc3545;
    --info:          #17a2b8;
    --sidebar-w:     240px;
    --sidebar-bg:    #3d1f35;
    --topbar-h:      56px;
    --bg:            #f4f1f8;
    --card-bg:       #ffffff;
    --text:          #333;
    --text-muted:    #888;
    --border:        #e0d6ea;
    --shadow:        0 2px 12px rgba(124,63,110,.12);
    --radius:        10px;
    --font:          'Nunito', 'Segoe UI', sans-serif;
    --transition:    .2s ease;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: width var(--transition), transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar.collapsed { width: 60px; }

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 16px 12px;
    background: var(--primary-dark);
    gap: 10px;
    min-height: 70px;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.brand-text { font-size: .9rem; font-weight: 700; line-height: 1.2; color: var(--accent-light); }
.sidebar-toggle {
    background: none; border: none; color: rgba(255,255,255,.7);
    font-size: 1.1rem; cursor: pointer; margin-left: auto; flex-shrink: 0;
    padding: 4px 6px; border-radius: 6px;
    transition: background var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }

.sidebar-menu { flex: 1; padding: 8px 0; }

/* Direct links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link i { font-size: .95rem; width: 18px; flex-shrink: 0; }
.sidebar-link:hover, .sidebar-link.active {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-left-color: var(--accent);
}

/* Collapsible sections */
.sidebar-section { }
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: rgba(255,255,255,.75);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    width: 100%;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    transition: all var(--transition);
}
.sidebar-collapse-btn i { font-size: .95rem; width: 18px; flex-shrink: 0; }
.sidebar-collapse-btn .arrow { margin-left: auto; font-size: .7rem; transition: transform var(--transition); }
.sidebar-collapse-btn.open .arrow { transform: rotate(180deg); }
.sidebar-collapse-btn:hover, .sidebar-collapse-btn.open {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-left-color: var(--accent);
}

.sidebar-collapse { display: none; background: rgba(0,0,0,.15); }
.sidebar-collapse.show { display: block; }
.sidebar-sub-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 40px;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: .82rem;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-sub-link i { font-size: .8rem; }
.sidebar-sub-link:hover, .sidebar-sub-link.active { color: var(--accent-light); background: rgba(255,255,255,.05); }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.1);
    background: rgba(0,0,0,.15);
    font-size: .82rem;
    color: rgba(255,255,255,.6);
    white-space: nowrap;
    overflow: hidden;
}
.logout-btn { color: rgba(255,255,255,.5); margin-left: auto; font-size: 1rem; }
.logout-btn:hover { color: var(--danger); }

/* Collapsed sidebar */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-collapse-btn span,
.sidebar.collapsed .sidebar-collapse-btn .arrow,
.sidebar.collapsed .sidebar-collapse,
.sidebar.collapsed .sidebar-footer span { display: none; }

/* ============================================================
   CONTENT WRAPPER & TOPBAR
   ============================================================ */

/* The sidebar is fixed-position, so the content wrapper just
   needs a left margin. It is a normal block element — NOT flex —
   so its children (topbar, page-content, footer) stack vertically
   and the footer always sits at the bottom after all content.     */
#content-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}
#content-wrapper.expanded { margin-left: 60px; }

/* Topbar — sticky strip at top of content area */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;    /* never squish the topbar */
}
.topbar-toggle {
    background: none; border: none; font-size: 1.1rem;
    color: var(--primary); cursor: pointer; padding: 6px;
    border-radius: 6px; display: none;
}
.topbar-brand { font-size: 1rem; font-weight: 800; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.topbar-date { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.topbar-user { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--primary); }
.btn-logout {
    background: var(--primary);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-size: .8rem;
    font-weight: 600;
    transition: background var(--transition);
}
.btn-logout:hover { background: var(--primary-dark); color: #fff; }

/* Main page content — grows to fill remaining vertical space */
#page-content {
    flex: 1;
    padding: 24px;
    /* Prevent any child grid/flex from expanding beyond this column */
    min-width: 0;
    overflow-x: hidden;
}

/* Footer — always full-width below page-content, never floating */
.app-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    font-size: .8rem;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;    /* never squish the footer */
    width: 100%;
    display: block;
}

/* ============================================================
   CARDS
   ============================================================ */
.dv-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.dv-card-header {
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dv-card-header i { font-size: 1rem; }
.dv-card-body { padding: 20px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-left: 4px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124,63,110,.18); }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 600; font-size: .85rem; color: var(--primary-dark); margin-bottom: 4px; }
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .88rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
    color: var(--text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124,63,110,.12);
    outline: none;
}
.form-control::placeholder { color: #bbb; }

/* Remove number arrows */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .85rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b8754f; color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #1e7e34; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bd2130; color: #fff; }
.btn-warning   { background: var(--warning); color: #212529; }
.btn-warning:hover { background: #d39e00; }
.btn-outline   { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 26px; font-size: .95rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; border-radius: var(--radius); }
.dv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.dv-table thead th {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 700;
    white-space: nowrap;
}
.dv-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.dv-table tbody tr:hover { background: #faf6fd; }
.dv-table td { padding: 10px 14px; vertical-align: middle; }
.dv-table .text-right { text-align: right; }
.dv-table .text-center { text-align: center; }

/* ============================================================
   ALERTS / BADGES
   ============================================================ */
.alert { border-radius: 8px; padding: 12px 16px; font-size: .88rem; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .3px;
}
.badge-primary { background: var(--primary); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-danger  { background: var(--danger); color: #fff; }
.badge-accent  { background: var(--accent); color: #fff; }

/* ============================================================
   BILL / RECEIPT SPECIFIC
   ============================================================ */
.bill-section-title {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--primary);
    font-weight: 700;
    border-bottom: 2px solid var(--accent-light);
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.bill-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: .88rem;
    border-bottom: 1px dashed var(--border);
}
.bill-totals-row.grand {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    border-bottom: none;
    border-top: 2px solid var(--primary);
    padding-top: 10px;
    margin-top: 4px;
}
.discount-badge {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
}

/* ============================================================
   PRINT RECEIPT
   ============================================================ */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    body { background: #fff !important; margin: 0; font-family: 'Courier New', monospace; }
    .no-print { display: none !important; }
    .sidebar, .topbar, .app-footer, #content-wrapper > .topbar { display: none !important; }
    #content-wrapper { margin-left: 0 !important; }
    #page-content { padding: 0 !important; }

    /* Thermal-style receipt */
    .receipt-print {
        width: 80mm;
        margin: 0 auto;
        font-size: 11px;
        line-height: 1.4;
    }
    .receipt-print .receipt-logo { text-align: center; margin-bottom: 8px; }
    .receipt-print .receipt-logo img { height: 50px; }
    .receipt-print .receipt-shop-name { text-align: center; font-weight: bold; font-size: 14px; }
    .receipt-print .receipt-divider { border-top: 1px dashed #000; margin: 6px 0; }
    .receipt-print table { width: 100%; font-size: 10px; }
    .receipt-print table td { padding: 2px 0; }
    .receipt-print .receipt-total { font-weight: bold; font-size: 13px; }
    .receipt-print .receipt-thank { text-align: center; margin-top: 8px; font-style: italic; }

    /* A4 invoice */
    .invoice-print { width: 100%; max-width: 720px; margin: 0 auto; font-size: 12px; }
    .invoice-print .inv-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
    .invoice-print .inv-shop-name { font-size: 22px; font-weight: 900; color: #5a2d50; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    overflow: hidden;
    display: flex;
    max-width: 860px;
    width: 100%;
}
.login-brand {
    flex: 1;
    background: linear-gradient(160deg, var(--primary-dark), var(--primary));
    padding: 48px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
}
.login-brand img { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; margin-bottom: 18px; border: 3px solid var(--accent); }
.login-brand h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 6px; }
.login-brand p { font-size: .9rem; opacity: .8; }
.login-form-area { flex: 1; padding: 48px 36px; }
.login-form-area h3 { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-bottom: 24px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    /* On tablets collapse sidebar layout to single column */
    .page-grid-sidebar,
    .page-grid-sidebar-right { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    .sidebar.mobile-open { transform: translateX(0); }
    #content-wrapper { margin-left: 0 !important; }
    .topbar-toggle { display: block; }
    .login-brand { display: none; }
    .login-card { max-width: 400px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    #page-content { padding: 16px; }
    .topbar-date, .topbar-user { display: none; }
    /* Stack ALL two-column page grids on mobile */
    .page-grid-2,
    .page-grid-sidebar,
    .page-grid-sidebar-right { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   PAGE LAYOUT GRIDS  (use these classes on page-level grids)
   ============================================================ */

/* Two equal columns — e.g. Add Product + Recent Products */
.page-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    /* Critical: prevent grid children from overflowing their column */
    min-width: 0;
}

/* Left sidebar + main — e.g. Billing form (380px) + cart */
.page-grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
    min-width: 0;
}

/* Reverse: narrow sidebar + main content (360px left + rest) */
.page-grid-sidebar-right {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: start;
    min-width: 0;
}

/* All direct grid children must have min-width:0 to prevent overflow */
.page-grid-2 > *,
.page-grid-sidebar > *,
.page-grid-sidebar-right > * {
    min-width: 0;
    /* DO NOT use overflow:hidden here — it clips card box-shadows.
       min-width:0 alone fixes the grid blowout for flex/grid children. */
}

/* ============================================================
   GLOBAL OVERFLOW GUARD
   ============================================================ */
/* Tables inside cards should scroll horizontally, not push layout */
.dv-card .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
/* Inputs and selects should never overflow their container */
input, select, textarea, button {
    max-width: 100%;
}
