/* Printing Press ERP Custom Styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* Color Variables Design System */
:root {
    --font-headers: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Light Mode HSL Values */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: rgba(255, 255, 255, 0.75);
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-primary-glow: rgba(59, 130, 246, 0.15);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-glow: rgba(16, 185, 129, 0.15);
    
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --transition-speed: 0.25s;
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --glass-blur: 12px;
    --glass-border: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] {
    /* Dark Mode HSL Values */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: rgba(30, 41, 59, 0.75);
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --brand-primary: #3b82f6;
    --brand-primary-hover: #60a5fa;
    --brand-primary-glow: rgba(96, 165, 250, 0.15);
    
    --success: #10b981;
    --success-hover: #34d399;
    --success-glow: rgba(52, 211, 153, 0.15);
    
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #22d3ee;
    
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    
    --glass-border: rgba(255, 255, 255, 0.05);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-headers);
    font-weight: 600;
    color: var(--text-primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Wrapper Layout */
#app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden; /* Prevents global page horizontal scrolling */
    width: 100%;
}

/* Premium Sidebar (Glassmorphism) */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
}

#sidebar .brand-area {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

#sidebar .brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-primary);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar .nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition-speed) ease;
}

#sidebar .nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

#sidebar .nav-item:hover, 
#sidebar .nav-item.active {
    background-color: var(--brand-primary-glow);
    color: var(--brand-primary);
}

#sidebar .nav-item.active {
    font-weight: 600;
}

#sidebar .nav-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin: 12px 16px 6px;
}

/* Main Content Area */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) ease;
    min-width: 0; /* Forces flex child to shrink within parent bounds instead of overflowing */
    overflow-x: hidden; /* Double defense against child overflow */
}

/* Topbar Header */
#topbar {
    height: var(--topbar-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: background-color var(--transition-speed);
}

/* Cards & Widgets */
.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed), background-color var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}
.stat-card .card-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Custom Table Styles */
.custom-table-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 30px;
}

.table {
    color: var(--text-primary);
    margin-bottom: 0;
}
.table th {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: var(--font-headers);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}
.table td {
    padding: 14px 20px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.table tr:last-child td {
    border-bottom: none;
}

/* Modals */
.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
}
.modal-footer {
    border-top: 1px solid var(--border-color);
}

/* Dynamic Forms */
.form-control, .form-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: all var(--transition-speed);
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.25rem var(--brand-primary-glow);
}
.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed);
}
.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}
.btn-success {
    background-color: var(--success);
    border-color: var(--success);
}
.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

/* Production Timeline Workflow Component */
.timeline-flow {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 30px 0;
}
.timeline-flow::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--border-color);
    z-index: 1;
}
.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    width: 100px;
}
.timeline-node {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: all 0.3s;
}
.timeline-step.active .timeline-node {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary);
    color: white;
    box-shadow: 0 0 0 4px var(--brand-primary-glow);
}
.timeline-step.completed .timeline-node {
    border-color: var(--success);
    background-color: var(--success);
    color: white;
    box-shadow: 0 0 0 4px var(--success-glow);
}
.timeline-label {
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}
.timeline-step.active .timeline-label {
    color: var(--brand-primary);
}
.timeline-step.completed .timeline-label {
    color: var(--success);
}

/* Notifications Toasts */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1055;
}

/* Responsive Overrides */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0 !important;
    }
}

/* Fix Action dropdown clipping in responsive tables on desktop */
@media (min-width: 992px) {
    .custom-table-card,
    .table-responsive {
        overflow: visible !important;
    }
}

/* ==========================================================================
   HIGH-FIDELITY MOBILE & TABLET RESPONSIVE SYSTEM OVERRIDES
   ========================================================================== */

/* 1. Global Viewport Adjustments & Spacing Scales */
@media (max-width: 767.98px) {
    #topbar {
        padding: 0 15px !important;
        height: 60px !important;
    }
    :root {
        --topbar-height: 60px !important;
    }
    #main-content > div.p-4 {
        padding: 15px !important;
    }
    .custom-table-card {
        margin-bottom: 20px !important;
    }
    footer {
        padding: 15px !important;
        font-size: 0.75rem !important;
    }
}

/* 2. Premium Sidebar Mobile Slide-out & Drop Shadow Overlay */
@media (max-width: 991.98px) {
    #sidebar {
        box-shadow: none;
        transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    }
    #sidebar.show {
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.35) !important;
    }
    #main-content {
        transition: padding var(--transition-speed) ease;
    }
}

/* 3. Dashboard Widget Cards Optimization */
@media (max-width: 575.98px) {
    .stat-card {
        padding: 16px !important;
    }
    .stat-card h3 {
        font-size: 1.25rem !important;
    }
    .stat-card .card-icon {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.2rem !important;
    }
    .stat-card span {
        font-size: 0.7rem !important;
    }
    
    /* Quick stats 2x2 grid */
    .col-6.col-lg-3 {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
}

/* 4. Production Workflow Timeline: Horizontal to Vertical Responsive Flow */
@media (max-width: 767.98px) {
    .timeline-flow {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 20px !important;
        padding-left: 20px !important;
        margin: 25px 0 !important;
    }
    .timeline-flow::before {
        top: 0 !important;
        bottom: 0 !important;
        left: 42px !important; /* Aligns precisely with the center of the 44px wide timeline-node (20px pad + 22px center) */
        width: 4px !important;
        height: 100% !important;
    }
    .timeline-step {
        flex-direction: row !important;
        width: 100% !important;
        gap: 15px !important;
        align-items: center !important;
    }
    .timeline-node {
        flex-shrink: 0 !important;
        z-index: 2 !important;
    }
    .timeline-label {
        margin-top: 0 !important;
        text-align: left !important;
        font-size: 0.85rem !important;
    }
}

/* 5. Responsive Tabular Data Optimization (Tightened Mobile Padding) */
@media (max-width: 767.98px) {
    .table th {
        padding: 10px 12px !important;
        font-size: 0.65rem !important;
    }
    .table td {
        padding: 10px 12px !important;
        font-size: 0.8rem !important;
    }
    
    /* Subtle horizontal scroll hints */
    .table-responsive {
        border-radius: var(--radius-sm);
        border: 1px solid var(--border-color);
        background: linear-gradient(to right, var(--bg-secondary) 30%, rgba(255,255,255,0)), 
                    linear-gradient(to right, rgba(255,255,255,0), var(--bg-secondary) 70%) 0 100%, 
                    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.1), rgba(0,0,0,0)), 
                    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.1), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* 6. Mobile Form & Modal Elements Alignment */
@media (max-width: 575.98px) {
    .form-control, .form-select {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }
    .modal-body {
        padding: 20px !important;
    }
    .modal-footer {
        padding: 12px 20px !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }
    .modal-footer .btn {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
    }
}

/* 7. Directory Header Bars & Filter Blocks Stack Controls */
@media (max-width: 767.98px) {
    .d-flex.justify-content-between.align-items-center.flex-wrap {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    .d-flex.justify-content-between.align-items-center.flex-wrap > div {
        text-align: left !important;
    }
    
    /* Make button columns stack vertically and stretch full-width on mobile/tablet */
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-2,
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-3 {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .d-flex.justify-content-between.align-items-center.flex-wrap .btn, 
    .d-flex.justify-content-between.align-items-center.flex-wrap a.btn,
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-2 .btn,
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-2 a.btn,
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-3 .btn,
    .d-flex.justify-content-between.align-items-center.flex-wrap .d-flex.gap-3 a.btn {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
        flex: 1 1 auto !important;
    }
    
    /* Directory filters wrapper (e.g. search bars, date inputs, filters) */
    .custom-table-card .p-3.border-bottom {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    .custom-table-card .p-3.border-bottom select,
    .custom-table-card .p-3.border-bottom .input-group {
        max-width: 100% !important;
        width: 100% !important;
    }
    .custom-table-card .p-3.border-bottom .d-flex.gap-2 {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}

/* 8. Corporate Printable & PDF Layout Sheets Mobile Scaling */
@media (max-width: 767.98px) {
    #printable-document,
    #voucher-print-area,
    .custom-table-card.p-5,
    .custom-table-card.p-4 {
        padding: 20px !important;
        border-radius: var(--radius-sm) !important;
    }
    
    /* Responsive headers flex elements */
    .custom-table-card.p-5 .border-bottom {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }
    
    .custom-table-card.p-5 .text-end {
        text-align: left !important;
    }
    
    .custom-table-card.p-5 .row.mb-4.g-3 {
        margin-bottom: 20px !important;
    }
    
    /* Tighten table and labels on screen */
    .receipt-voucher-print {
        padding: 15px !important;
    }
    .receipt-voucher-print .bg-light,
    .receipt-voucher-print [style*="background-color"] {
        padding: 12px !important;
    }
}

/* Clickable Table Rows styling */
tr.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
tr.clickable-row:hover {
    background-color: var(--print-accent-light, #f0f6ff) !important;
}
body[data-theme="dark"] tr.clickable-row:hover {
    background-color: rgba(59, 130, 246, 0.15) !important;
}




