/* Premium CSS with Glassmorphism & Responsive Design */
:root {
    --primary: #0284C7;
    --primary-hover: #0369A1;
    --secondary: #10B981;
    --secondary-hover: #059669;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --info: #3B82F6;
    
    --bg-color: #F8FAFC;
    --text-main: #0F172A;
    --text-muted: #475569;
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(2, 132, 199, 0.15);
    --glass-shadow: 0 10px 30px rgba(2, 132, 199, 0.08);
    
    --font-primary: 'Outfit', sans-serif;
    --font-secondary: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-secondary);
    background: linear-gradient(135deg, #E0F2FE 0%, #F8FAFC 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 {
    font-family: var(--font-primary);
    font-weight: 600;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font-primary); }

/* Utility Classes */
.hidden { display: none !important; }
.active { display: block; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: #34D399; }
.text-danger { color: #F87171; }
.font-bold { font-weight: 700; }

/* Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

/* Layout */
#app {
    width: 100%;
    min-height: 100vh;
}

/* Login View */
#login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    animation: fadeIn 0.5s ease-out;
}
.login-header {
    text-align: center;
    margin-bottom: 30px;
}
.avatar-circle {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 auto 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}
.avatar-circle svg { width: 40px; height: 40px; }

/* Form Elements */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}
.form-row > .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}
.form-row > .form-group.full-width {
    flex: 1 1 100%;
}
.form-row.align-end {
    align-items: flex-end;
}
.form-group.auto-width {
    flex: 0 1 auto;
    min-width: auto;
}

label {
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
input, select, textarea {
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid rgba(2, 132, 199, 0.2);
    background: rgba(255, 255, 255, 0.9);
    color: #0F172A;
    font-family: var(--font-secondary);
    transition: all 0.3s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

/* Fix select options on light mode */
select option { background: white; color: #0F172A; }

/* Buttons */
button {
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    display: inline-block;
}
button:hover { transform: translateY(-2px); }
button:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3); }
.w-full { width: 100% !important; }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: var(--secondary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: rgba(2, 132, 199, 0.05); color: var(--primary); border: 1px solid rgba(2, 132, 199, 0.15); }
.btn-secondary:hover { background: rgba(2, 132, 199, 0.1); }
.btn-text { background: transparent; color: var(--danger); padding: 5px 10px; }
.icon-btn { background: transparent; color: var(--text-main); padding: 5px; border-radius: 4px; }

/* Main Layout */
#main-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    border-left: none;
    border-top: none;
    border-bottom: none;
    transition: transform 0.3s ease;
    z-index: 100;
}
.brand {
    padding: 20px;
    font-size: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(2, 132, 199, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-links {
    list-style: none;
    flex: 1;
    padding: 20px 0;
}
.nav-links li a {
    display: block;
    padding: 15px 25px;
    color: var(--text-muted);
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
}
.nav-links li a:hover, .nav-links li a.active {
    color: var(--primary);
    background: rgba(2, 132, 199, 0.08);
    border-left-color: var(--primary);
}
.user-info {
    padding: 20px;
    border-top: 1px solid rgba(2, 132, 199, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.topbar {
    padding: 15px 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 0;
    border-bottom: 1px solid var(--glass-border);
}

.page-view {
    padding: 30px;
    animation: fadeIn 0.4s ease-out;
}
.card {
    padding: 25px;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* Tables */
.table-container { padding: 0; overflow: hidden; }
.table-actions {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(2, 132, 199, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.responsive-table {
    width: 100%;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
th, td {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(2, 132, 199, 0.1);
}
th {
    background: rgba(2, 132, 199, 0.08);
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
}
tbody tr:hover { background: rgba(2, 132, 199, 0.03); }
tfoot { background: rgba(2, 132, 199, 0.06); color: var(--text-main); }
tfoot td { font-size: 1.1rem; color: var(--text-main) !important; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal.hidden { display: none !important; }
.modal-content {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    background: #fff; /* White bg for receipt printing */
    color: #333;
}
.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.1);
    color: #333;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
}
.modal-actions { margin-top: 20px; text-align: center; }

/* Receipt Layout */
.receipt-layout {
    display: flex;
    flex-direction: column;
    height: 270mm;
    justify-content: space-between;
    font-size: 11px;
    color: #000 !important;
    box-sizing: border-box;
}
.receipt-part {
    height: 128mm;
    border: 1px dashed #555;
    padding: 15px;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}
.receipt-top-section {
    display: block;
}
.receipt-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}
.receipt-header h2 {
    font-size: 1.3rem;
    margin-bottom: 2px;
    color: #000;
}
.receipt-info-table {
    width: 100%;
    margin-bottom: 8px;
    border-collapse: collapse;
}
.receipt-info-table td {
    padding: 2px 0 !important;
    border: none !important;
    color: #000 !important;
    font-size: 11px;
}
.receipt-table {
    width: 100%;
    border: 1px solid #000;
    margin-bottom: 10px;
}
.receipt-table th, .receipt-table td {
    border: 1px solid #000;
    padding: 6px 10px;
    color: #000 !important;
    background: transparent !important;
}
.receipt-table th {
    background: #f0f0f0 !important;
}
.receipt-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    text-align: center;
}
.sig-box {
    width: 220px;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Responsiveness */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .mobile-only { display: block; }
    
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    
    .topbar { padding: 15px; }
    .page-view { padding: 15px; }
    
    .form-row { flex-direction: column; gap: 10px; }
    .form-group { min-width: 100%; }
    .form-row.align-end { align-items: stretch; }
    
    th, td { padding: 10px; font-size: 0.9rem; }
}

/* Print Styles */
@media print {
    @page {
        margin: 15mm;
    }
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area {
        position: absolute;
        left: 0; top: 0;
        width: 100%;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .print-area table {
        background: white !important;
        color: black !important;
        border: 1px solid #000 !important;
        border-collapse: collapse !important;
    }
    .print-area th, .print-area td {
        color: black !important;
        border: 1px solid #000 !important;
        background: transparent !important;
        padding: 6px 10px !important;
    }
    .print-area th {
        background: #f0f0f0 !important;
    }
    .print-area tfoot {
        display: table-row-group !important;
    }
    .no-print, .no-print * { display: none !important; }
}

/* Sidebar Collapse on Desktop */
@media (min-width: 769px) {
    .sidebar {
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s, opacity 0.3s, border 0.3s;
        width: 260px;
        flex-shrink: 0;
    }
    .sidebar.collapsed {
        width: 0px !important;
        padding: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        border-right: none !important;
    }
}
.desktop-only { display: block; }
@media (max-width: 768px) {
    .desktop-only { display: none !important; }
}
