/* ====================================================
   Pawn System — Custom Stylesheet
   ===================================================== */

:root {
    --sidebar-width: 255px;
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #b0b8cc;
    --sidebar-active: #f59e0b;
    --sidebar-hover-bg: rgba(255,255,255,.07);
    --topbar-height: 58px;
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --body-bg: #f4f6fb;
    --card-radius: 12px;
}

/* ── Body & Layout ── */
body {
    font-family: 'Sarabun', 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: #1e293b;
    margin: 0;
    overflow-x: hidden;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width .3s ease, transform .3s ease;
    overflow-x: hidden;
}

#sidebar.collapsed {
    width: 64px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 20px 18px;
    color: var(--sidebar-active);
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i { font-size: 1.4rem; flex-shrink: 0; }
#sidebar.collapsed .sidebar-brand span,
#sidebar.collapsed .sidebar-nav a span,
#sidebar.collapsed .sidebar-footer { display: none; }
#sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 12px 0; }
#sidebar.collapsed .sidebar-nav a i { margin: 0 !important; }
#sidebar.collapsed .sidebar-separator { display: none; }

.sidebar-nav {
    flex: 1;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    overflow-y: auto;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    transition: background .2s, color .2s;
    border-radius: 0 30px 30px 0;
    margin-right: 12px;
    white-space: nowrap;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover-bg);
    color: #fff;
}

.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: #000;
    font-weight: 600;
}

.sidebar-nav li a i { width: 20px; text-align: center; }

.sidebar-separator {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 8px 18px;
}

.sidebar-footer {
    padding: 12px 18px;
    font-size: .75rem;
    color: rgba(255,255,255,.3);
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Content Wrapper ── */
#content-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    transition: margin-left .3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#content-wrapper.expanded { margin-left: 64px; }

/* ── Top Navbar ── */
.top-navbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    color: #64748b;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background .2s;
}
.sidebar-toggle-btn:hover { background: #f1f5f9; }

.top-navbar-right { margin-left: auto; display: flex; align-items: center; }

.user-menu-btn { color: #475569; font-size: .9rem; }
.user-menu-btn:hover { color: #0f172a; }

/* ── Page Content ── */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e8ecf1;
    padding: 16px 20px;
    font-weight: 600;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: var(--card-radius);
    padding: 20px 22px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute; right: 18px; top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: .2;
}

.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: .82rem; opacity: .85; margin-top: 2px; }

.stat-amber    { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-green    { background: linear-gradient(135deg, #10b981, #059669); }
.stat-red      { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-blue     { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-purple   { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-teal     { background: linear-gradient(135deg, #14b8a6, #0d9488); }

/* ── Buttons ── */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #000;
}

/* ── Tables ── */
.table th {
    font-weight: 600;
    font-size: .85rem;
    color: #475569;
    background: #f8fafc;
    border-color: #e2e8f0;
}
.table td { vertical-align: middle; font-size: .9rem; }
.table > :not(caption) > * > * { border-color: #e8ecf1; }

/* ── Forms ── */
.form-label { font-weight: 500; font-size: .85rem; color: #475569; margin-bottom: 5px; }
.form-control, .form-select {
    border-color: #d1d9e0;
    border-radius: 8px;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(245,158,11,.2);
}

/* ── Badges ── */
.badge { font-weight: 500; padding: .4em .7em; font-size: .78rem; }

/* ── Page title row ── */
.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-title-row h4 { margin: 0; font-weight: 700; color: #1e293b; }

/* ── Ticket / Print ── */
@media print {
    #sidebar, .top-navbar, .no-print, .btn, nav { display: none !important; }
    #content-wrapper { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    body { background: #fff; }
}

.ticket-wrap {
    max-width: 420px;
    margin: 0 auto;
    border: 2px dashed #333;
    border-radius: 10px;
    padding: 24px;
    font-size: .9rem;
    background: #fff;
}
.ticket-wrap .ticket-header { text-align: center; margin-bottom: 16px; }
.ticket-wrap .ticket-header h5 { font-weight: 700; font-size: 1.1rem; margin: 0; }
.ticket-wrap .ticket-no { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); }
.ticket-divider { border-top: 1px dashed #aaa; margin: 10px 0; }
.ticket-row { display: flex; justify-content: space-between; margin-bottom: 5px; }
.ticket-row .label { color: #666; }
.ticket-row .value { font-weight: 600; }

/* ── Interest Calculator Preview ── */
.interest-preview-box {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px 16px;
}

/* ── Overdue highlight in tables ── */
tr.overdue-row td { background-color: #fff5f5 !important; }
tr.due-soon-row td { background-color: #fffbeb !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        z-index: 1050;
    }
    #sidebar.mobile-open { transform: translateX(0); }
    #content-wrapper { margin-left: 0 !important; }
    .page-content { padding: 16px; }
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3561 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-box .login-logo { text-align: center; margin-bottom: 8px; color: var(--primary); font-size: 3rem; }
.login-box h4 { text-align: center; font-weight: 700; margin-bottom: 6px; }
.login-box .subtitle { text-align: center; color: #94a3b8; font-size: .85rem; margin-bottom: 28px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
