/* =========================================================
   GENERAL VARIABLES & RESETS
   ========================================================= */
:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --primary: #f59e0b;
    /* Default for Admin, can be overridden by specific page classes */
    --text-main: #f8fafc;
    --text-muted: #cbd5f5;
    --border: #334155;
    --danger: #ef4444;
    --success: #22c55e;
    --sidebar-width: 260px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* =========================================================
   LOGIN PAGE STYLES (Add 'login-page' class to body)
   ========================================================= */
body.login-page {
    height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1e293b, #334155);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
}

.login-container {
    width: 360px;
    padding: 35px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.login-container h2 {
    margin-bottom: 20px;
    font-weight: 600;
}

.login-container .error {
    color: #f87171;
    font-size: 14px;
    margin-bottom: 10px;
}

.login-container .input-group {
    position: relative;
    margin-bottom: 18px;
}

.login-container .input-group i {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: #94a3b8;
}

.login-container .input-group input {
    width: 100%;
    padding: 12px 12px 12px 38px;
    border-radius: 8px;
    border: none;
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: 0.3s;
}

.login-container .input-group input:focus {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px #38bdf8;
}

.login-container button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.login-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.4);
}

.login-container .footer {
    margin-top: 15px;
    font-size: 13px;
    color: #94a3b8;
}

/* =========================================================
   DASHBOARD STYLES (Admin, Staff, Billing)
   Add 'dashboard-page' class to body
   ========================================================= */
body.dashboard-page {
    display: flex;
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* STAFF THEME OVERRIDE */
body.staff-dashboard {
    --primary: #22c55e;
}

/* OVERLAY FOR MOBILE */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    position: fixed;
    transition: var(--transition);
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    text-align: center;
    margin-bottom: 40px;
    color: var(--primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    letter-spacing: 0.5px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 14px 16px;
    margin: 6px 0;
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(30, 41, 59, 0.8);
    color: var(--primary);
    transform: translateX(5px);
}

/* LOGOUT */
.logout {
    margin-top: auto;
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--danger) !important;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.logout:hover {
    background: var(--danger) !important;
    color: white !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* MAIN CONTENT */
.main {
    margin-left: var(--sidebar-width);
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition);
}

.main.grid-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 30px;
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(30, 41, 59, 0.5);
    padding: 15px 25px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-top {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.menu-btn {
    font-size: 24px;
    cursor: pointer;
    display: none;
    color: var(--text-main);
    transition: var(--transition);
}

.menu-btn:hover {
    color: var(--primary);
}

.header h1,
.header-title {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-title {
    font-size: 1.8rem;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* CARDS */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.card {
    background: linear-gradient(145deg, var(--bg-card), rgba(30, 41, 59, 0.4));
    padding: 25px;
    border-radius: 16px;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

body.dashboard-page .card:hover {
    border-color: rgba(245, 158, 11, 0.3);
}

body.staff-dashboard .card:hover {
    border-color: rgba(34, 197, 94, 0.3);
}

.card:hover::before {
    opacity: 1;
}

.card i {
    font-size: 28px;
    margin-bottom: 15px;
    color: var(--primary);
    background: rgba(245, 158, 11, 0.1);
    padding: 15px;
    border-radius: 12px;
    display: inline-block;
}

body.staff-dashboard .card i {
    background: rgba(34, 197, 94, 0.1);
}

.card h3 {
    font-size: 1.4rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
}

/* FORM / BOX SECTION */
.box {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.box h3 {
    margin-bottom: 20px;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
}

select.form-control option {
    background: var(--bg-card);
    color: #fff;
}

.btn-add {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 10px;
}

.btn-add:hover {
    filter: brightness(0.9);
    transform: translateY(-2px);
}

.status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status.pending,
.pending {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status.completed,
.completed {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ACTION BUTTONS */
.btn {
    padding: 8px 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    color: var(--success);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn:hover {
    background: var(--success);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.2);
}

.btn-view {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.btn-view:hover {
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

/* RECEIPT PREVIEW */
.receipt-container {
    background: #fff;
    color: #000;
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
    font-family: 'Space Mono', monospace;
}

.receipt-header {
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 1px dashed #000;
    padding-bottom: 10px;
}

.receipt-header h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.receipt-header p {
    font-size: 0.85rem;
    margin: 2px 0;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.receipt-table th {
    border-bottom: 1px dashed #000;
    padding-bottom: 5px;
    text-align: left;
}

.receipt-table td {
    padding: 5px 0;
}

.receipt-table td.qty {
    text-align: center;
}

.receipt-table td.price,
.receipt-table th.price {
    text-align: right;
}

.receipt-totals {
    border-top: 1px dashed #000;
    padding-top: 10px;
    margin-bottom: 15px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.total-row.grand-total {
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #000;
}

.receipt-footer {
    text-align: center;
    font-size: 0.85rem;
    border-top: 1px dashed #000;
    padding-top: 10px;
}

.btn-print {
    width: 100%;
    padding: 15px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: var(--transition);
}

.btn-print:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.delete-btn {
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
}

/* RESPONSIVE DESIGN */
@media (max-width: 992px) {
    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .main.grid-layout {
        grid-template-columns: 1fr;
    }

    .receipt-container {
        margin-top: 20px;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .menu-btn {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

    .header {
        padding: 12px 20px;
    }

    .header h1 {
        font-size: 1.2rem;
        display: none;
    }

    .header-title {
        font-size: 1.4rem;
        display: block;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .user {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

}

@media (min-width: 480px) and (max-width: 768px) {
    .header h1 {
        display: block;
    }
}

/* PRINT MEDIA QUERY */
@media print {
    body * {
        visibility: hidden;
    }

    body,
    html {
        background: #fff !important;
        margin: 0;
        padding: 0;

    }

    .receipt-container,
    .receipt-container * {
        visibility: visible;
    }

    .receipt-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        margin: 0;
        padding: 5mm;
        border-radius: 0;
        box-shadow: none;
    }

    .delete-btn {
        display: none !important;
    }

    th.action-col {
        display: none !important;
    }

    td.action-col {
        display: none !important;
    }
}