/* ===== Stock Mania - Custom Styles ===== */

:root {
    --primary:    #1a3c5e;
    --primary-lt: #2563a8;
    --accent:     #f59e0b;
    --sidebar-w:  260px;
    --topbar-h:   58px;
    --bg:         #f0f4f8;
    --card-bg:    #ffffff;
    --text:       #1e293b;
    --muted:      #64748b;
    --border:     #e2e8f0;
    --success:    #10b981;
    --danger:     #ef4444;
    --warning:    #f59e0b;
    --info:       #3b82f6;
}

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .25s ease;
}

#sidebar .brand {
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 10px;
}

#sidebar .brand .logo-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff; font-weight: 700;
}

#sidebar .brand .brand-text { color: #fff; }
#sidebar .brand .brand-text .title { font-size: 16px; font-weight: 700; }
#sidebar .brand .brand-text .sub   { font-size: 11px; opacity: .6; }

/* Nav */
#sidebar nav { flex: 1; padding: 8px 0; }

.nav-section-title {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
}

.nav-item { display: block; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: all .15s;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: var(--accent);
}

.nav-link .nav-icon { width: 18px; text-align: center; font-size: 15px; }
.nav-link .nav-arrow { margin-left: auto; font-size: 11px; transition: transform .2s; }
.nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

/* Sub-menu */
.nav-sub { display: none; background: rgba(0,0,0,.15); }
.nav-sub.show { display: block; }
.nav-sub .nav-link { padding-left: 48px; font-size: 13px; }

/* Sidebar Footer */
#sidebar .sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.6);
    font-size: 12px;
}

/* ===== Topbar ===== */
#topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

#topbar .page-title { font-size: 16px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-right .user-info { text-align: right; }
.topbar-right .user-info .uname { font-size: 13px; font-weight: 600; }
.topbar-right .user-info .urole { font-size: 11px; color: var(--muted); }

.topbar-right .avatar {
    width: 36px; height: 36px;
    background: var(--primary-lt);
    border-radius: 50%;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    cursor: pointer;
}

/* ===== Main Content ===== */
#main {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

.page-content { padding: 24px; }

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border-radius: 10px 10px 0 0;
}

.card-body { padding: 18px; }

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-info .stat-val { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-info .stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

/* DataTable overrides */
.dataTables_wrapper {
    padding: 16px 18px;
}

/* Bootstrap 5 row/col grid stubs — only what DataTables needs */
.dataTables_wrapper .row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}
.dataTables_wrapper .row > [class*="col-"] {
    padding: 0 8px;
    box-sizing: border-box;
}
.dataTables_wrapper .col-sm-12 { width: 100%; }
.dataTables_wrapper .col-md-5  { flex: 0 0 41.666%; max-width: 41.666%; }
.dataTables_wrapper .col-md-6  { flex: 0 0 50%;     max-width: 50%; }
.dataTables_wrapper .col-md-7  { flex: 0 0 58.333%; max-width: 58.333%; }

/* Make the table row scrollable on narrow screens */
.dataTables_wrapper .dt-row { overflow-x: auto; }

/* Controls */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { margin-bottom: 12px; font-size: 13px; }
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.dataTables_wrapper .dataTables_filter { text-align: right; }
.dataTables_wrapper .dataTables_filter input { margin-left: 6px; }

/* Bottom: info left, pagination right */
.dataTables_wrapper .dataTables_info    { font-size: 13px; color: var(--muted); padding-top: 10px; }
.dataTables_wrapper .dataTables_paginate { text-align: right; }

/* Pagination — Bootstrap 5 .pagination styles (not loaded since we use custom CSS) */
.pagination {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    gap: 3px;
}
.pagination .page-item { list-style: none; }
.pagination .page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.pagination .page-item .page-link:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}
.pagination .page-item.active .page-link,
.pagination .page-item.active .page-link:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    color: var(--muted);
    pointer-events: none;
    background: #f8fafc;
    border-color: var(--border);
}
.dataTables_wrapper .dataTables_paginate { margin-top: 8px; }
.dataTables_wrapper .dataTables_info    { font-size: 13px; color: var(--muted); padding-top: 10px; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 50px;
    font-size: 11px; font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f1f5f9; color: #475569; }

/* ===== Forms ===== */
.form-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; display: block; }

.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s;
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-lt);
    box-shadow: 0 0 0 3px rgba(37, 99, 168, .1);
}

.input-group { display: flex; }
.input-group .form-control { border-radius: 7px 0 0 7px; flex: 1; }
.input-group .btn { border-radius: 0 7px 7px 0; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: 7px;
    font-size: 13.5px; font-weight: 500;
    border: none; cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary   { background: var(--primary);    color: #fff; }
.btn-primary:hover { background: var(--primary-lt); color: #fff; }
.btn-success   { background: var(--success);    color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger    { background: var(--danger);     color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; }
.btn-warning   { background: var(--warning);    color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-icon      { padding: 6px 8px; }

/* ===== Invoice Items Table ===== */
.invoice-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.invoice-table th { font-size: 12px; }
.invoice-table td input, .invoice-table td select {
    border: none; background: transparent; width: 100%;
    padding: 4px; outline: none; font-size: 13px;
}
.invoice-table td input:focus { background: #f0f9ff; border-radius: 4px; }
.invoice-table tfoot td { background: #f8fafc; font-weight: 600; }

/* ===== GST Summary ===== */
.gst-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.gst-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.gst-row.total { font-size: 16px; font-weight: 700; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex; align-items: center; gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.show { display: flex; }

.modal-dialog {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease;
}

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

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 15px;
}

.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }

/* ===== Utilities ===== */
.text-muted    { color: var(--muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.fs-12         { font-size: 12px; }
.fs-13         { font-size: 13px; }
.gap-2         { gap: 8px; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-2          { margin-top: 8px; }
.mt-3          { margin-top: 12px; }
.mt-4          { margin-top: 16px; }
.mb-2          { margin-bottom: 8px; }
.mb-3          { margin-bottom: 12px; }
.mb-4          { margin-bottom: 16px; }
.p-3           { padding: 12px; }
.p-4           { padding: 16px; }
.w-100         { width: 100%; }
.text-right    { text-align: right; }
.rounded       { border-radius: 8px; }
.border        { border: 1px solid var(--border); }

/* Grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col { flex: 1; padding: 0 10px; }
.col-2 { flex: 0 0 16.66%; padding: 0 10px; }
.col-3 { flex: 0 0 25%; padding: 0 10px; }
.col-4 { flex: 0 0 33.33%; padding: 0 10px; }
.col-6 { flex: 0 0 50%; padding: 0 10px; }
.col-8 { flex: 0 0 66.66%; padding: 0 10px; }
.col-12 { flex: 0 0 100%; padding: 0 10px; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #2d6ca8 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-circle {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff; font-weight: 800;
    margin: 0 auto 12px;
}

.login-logo h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo p  { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Responsive */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #topbar { left: 0; }
    #main   { margin-left: 0; }
}
