/* Base & Reset Styles */
:root {
    --bg-body: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #0f172a;
    --text-muted: #64748b;
    
    /* Theme Accents */
    --primary: #2563eb;
    --primary-light: rgba(37, 99, 235, 0.1);
    
    --secondary: #7c3aed;
    --secondary-light: rgba(124, 58, 237, 0.1);
    
    --success: #16a34a;
    --success-light: rgba(22, 163, 74, 0.1);
    
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.1);
    
    /* Category Colors */
    --color-excavator: #d97706; /* Gold/Amber */
    --excavator-light: rgba(217, 119, 6, 0.1);
    
    --color-truck: #4f46e5; /* Indigo */
    --truck-light: rgba(79, 70, 229, 0.1);
    
    --color-durian: #059669; /* Emerald/Green */
    --durian-light: rgba(5, 150, 105, 0.1);
    
    --font-thai: 'Prompt', sans-serif;
    --font-eng: 'Inter', sans-serif;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-body);
    color: var(--text-color);
    font-family: var(--font-thai);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout Structure */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation (White Clean Sidebar) */
.sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2.5rem;
}

.brand-icon {
    font-size: 2rem;
    color: var(--primary);
}

.brand-text h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
}

.brand-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.15rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.menu-item:hover {
    color: var(--text-color);
    background: var(--bg-body);
}

.menu-item.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.menu-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    flex-grow: 1;
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-title h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.2rem;
}

.text-muted {
    color: var(--text-muted);
}

.date-badge {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-color);
    box-shadow: var(--shadow-sm);
}

/* Tab Management */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glass/Modern Panels (Styled for Light Theme) */
.grid-form-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

.panel-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(248, 250, 252, 0.8);
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.panel-body {
    padding: 1.5rem;
    flex-grow: 1;
}

/* Form Controls & Inputs */
.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--card-bg);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    color: var(--text-color);
    font-family: var(--font-thai);
    font-size: 0.9rem;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.col-6 {
    flex: 1;
}
.col-4 {
    flex: 1;
}

.form-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Button UI */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.35rem;
    font-family: var(--font-thai);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-outline {
    background: var(--card-bg);
    border: 1px solid #cbd5e1;
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--bg-body);
    border-color: #94a3b8;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-excavator {
    border-color: rgba(217, 119, 6, 0.3);
    color: var(--color-excavator);
}
.btn-excavator:hover {
    background: var(--excavator-light);
}

.btn-truck {
    border-color: rgba(79, 70, 229, 0.3);
    color: var(--color-truck);
}
.btn-truck:hover {
    background: var(--truck-light);
}

.btn-durian {
    border-color: rgba(5, 150, 105, 0.3);
    color: var(--color-durian);
}
.btn-durian:hover {
    background: var(--durian-light);
}

/* Quick Actions Cards Hover styling */
.quick-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg) !important;
    filter: brightness(0.97);
}

/* Item Builder inside Receipt Creator */
.item-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.item-builder-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

.receipt-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.no-items-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1.75rem 0;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
}

.builder-item-row {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.builder-item-row.item-excavator { border-left: 4px solid var(--color-excavator); }
.builder-item-row.item-truck { border-left: 4px solid var(--color-truck); }
.builder-item-row.item-durian { border-left: 4px solid var(--color-durian); }

.item-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-badge {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.item-excavator .item-badge { background: var(--excavator-light); color: var(--color-excavator); }
.item-truck .item-badge { background: var(--truck-light); color: var(--color-truck); }
.item-durian .item-badge { background: var(--durian-light); color: var(--color-durian); }

.item-row-body {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}

/* Receipt Summary Inside Form */
.receipt-summary-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-line.grand-total {
    border-top: 1px solid var(--border-color);
    padding-top: 0.6rem;
    margin-top: 0.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Live Preview Paper Receipt Styling */
.preview-scroll-container {
    max-height: 550px;
    overflow-y: auto;
    padding: 0.25rem;
}

.receipt-paper-wrapper {
    background: white;
    color: #1e293b;
    padding: 2rem;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #cbd5e1;
}

/* Custom Table Styles */
.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.custom-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.custom-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.custom-table tr:hover td {
    background: rgba(248, 250, 252, 0.5);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Radio Type Selector (Durian Bookkeeper) */
.type-selector {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
}

.type-selector input[type="radio"] {
    display: none;
}

.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.type-selector input[type="radio"]:checked + .radio-label.label-income {
    background: var(--durian-light);
    border-color: var(--color-durian);
    color: var(--color-durian);
}

.type-selector input[type="radio"]:checked + .radio-label.label-expense {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* Recent Transaction Activities List */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.recent-item-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.recent-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.icon-excavator { background: var(--excavator-light); color: var(--color-excavator); }
.icon-truck { background: var(--truck-light); color: var(--color-truck); }
.icon-durian { background: var(--durian-light); color: var(--color-durian); }
.icon-expense { background: var(--danger-light); color: var(--danger); }

.recent-item-desc h5 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.recent-item-desc p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-item-price {
    font-family: var(--font-eng);
    font-weight: 700;
}

.price-income { color: var(--success); }
.price-expense { color: var(--danger); }

/* Table action buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.25rem 0.45rem;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.05);
}

.btn-icon.delete-btn:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.btn-icon.print-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* Custom Table Responsive */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* Screen Preview for signatures */
.print-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    margin-top: 3rem;
    text-align: center;
    font-size: 11px;
}

.sig-line {
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 0.5rem;
    height: 45px;
}

/* ----------------------------------------------------
   PRINT STYLES (Professional Document Styling)
   ---------------------------------------------------- */
.print-only {
    display: none;
}

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-family: 'Prompt', 'Inter', sans-serif !important;
    }
    
    .print-only {
        display: block !important;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .receipt-print {
        background: white !important;
        color: #1e293b !important;
        font-size: 12px !important;
        line-height: 1.6 !important;
        width: 100% !important;
        max-width: 800px !important;
        margin: 0 auto !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .receipt-print-header {
        display: flex;
        justify-content: space-between;
        border-bottom: 2px solid #334155;
        padding-bottom: 1.5rem;
        margin-bottom: 2rem;
    }

    .company-info h2 {
        font-size: 20px;
        font-weight: 700;
        color: #0f172a;
    }

    .receipt-title-box {
        text-align: right;
    }

    .receipt-title-box h1 {
        font-size: 24px;
        font-weight: 700;
        color: #0f172a;
        margin-bottom: 0.5rem;
    }

    .receipt-meta-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        margin-bottom: 2rem;
    }

    .meta-block h4 {
        border-bottom: 1px solid #cbd5e1;
        padding-bottom: 0.25rem;
        margin-bottom: 0.5rem;
        font-size: 13px;
        color: #475569;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 2.5rem;
    }

    .print-table th {
        background: #f1f5f9;
        border: 1px solid #cbd5e1;
        padding: 8px 12px;
        text-align: left;
        font-weight: 600;
        color: #1e293b;
    }

    .print-table td {
        border: 1px solid #cbd5e1;
        padding: 8px 12px;
    }

    .print-total-section {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 3rem;
    }

    .print-total-box {
        width: 300px;
        border-collapse: collapse;
    }

    .print-total-box td {
        padding: 6px 12px;
    }

    .print-total-box tr.final-row td {
        border-top: 2px double #1e293b;
        border-bottom: 2px double #1e293b;
        font-weight: 700;
        font-size: 14px;
        color: #0f172a;
    }

    .print-signatures {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
        margin-top: 4rem;
        text-align: center;
    }

    .sig-line {
        border-bottom: 1px solid #94a3b8;
        margin-bottom: 0.5rem;
        height: 60px;
    }
}

/* ----------------------------------------------------
   MOBILE RESPONSIVENESS (Mobile & Tablet Layouts)
   ---------------------------------------------------- */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        width: 280px;
        height: 100vh;
        background: var(--card-bg);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
        transition: transform 0.3s ease;
        top: 0;
        left: 0;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
    }
    
    .content-header {
        margin-bottom: 1.25rem;
    }
    
    .header-title h2 {
        font-size: 1.3rem;
    }
    
    .header-title p {
        font-size: 0.75rem;
    }
    
    .date-badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }
    
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
    
    /* Responsive Grids */
    .grid-form-layout {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
    
    /* Dashboard Split business cards */
    #dashboard > div:nth-child(2) {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row .col-6,
    .form-row .col-4 {
        width: 100%;
    }
    
    .builder-item-row .item-row-body {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .builder-item-row .item-row-body .form-group {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .builder-item-row .item-row-body .text-right {
        text-align: left;
    }
}

