/* assets/css/style.css - PROFESSIONAL UI V2 */

/* 1. IMPORTS & FONTS */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Modern Gradient Palette */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* Deep Purple/Blue */
    --secondary-gradient: linear-gradient(135deg, #2af598 0%, #009efd 100%);
    /* Fresh Green/Blue */
    --danger-gradient: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    /* Soft Red */

    /* Solid Colors for Text */
    --primary-color: #6a11cb;
    --text-dark: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;

    /* Surfaces */
    --bg-color: #f3f4f6;
    /* Very light gray, not stark white */
    --card-bg: #ffffff;
    --sidebar-width: 260px;

    /* Shadows - The key to "Professional" looks */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* 2. GLOBAL RESETS */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    /* Professional, rounded font */
    background-color: var(--bg-color);
    color: var(--text-dark);
    font-size: 0.95rem;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
}

/* 3. ANIMATIONS */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

/* Apply fade in to main content */
.main-content {
    animation: fadeIn 0.6s ease-out;
}

/* 4. SIDEBAR - Modern & Gradient */
/* assets/css/style.css - DARK SIDEBAR FIX */

/* 3. SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: #1e1e2d;
    /* Professional Dark Slate */
    color: #a2a3b7;
    /* Muted Text Color for readability */
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    /* Subtle shadow */
}
.sidebar-header {
    padding: 30px 20px;
    /* Increased padding for larger logo */
    font-size: 1.1rem;
    /* Slightly smaller font to fit logo */
    font-weight: 700;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;

    /* NEW: Flexbox for side-by-side alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* Space between logo and text */
}

/* NEW: Logo Styling */
.sidebar-logo {
    height: 70px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.sidebar ul {
    padding-top: 20px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar ul li a {
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #a2a3b7;
    /* Light Gray Text */
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar ul li a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Hover & Active States */
.sidebar ul li a:hover,
.sidebar ul li a.active {
    background: rgba(255, 255, 255, 0.05);
    /* Glassy effect */
    color: #ffffff;
    /* Bright White Text */
    border-left-color: var(--primary-color);
    /* Purple Accent Line */
}

/* Sidebar Footer (Logout Area) */
.sidebar-footer {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    /* Darker footer background */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Logout Button Style */
.btn-logout-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    /* Transparent Red */
    color: #ef4444;
    /* Red Text */
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s;
}

.btn-logout-sidebar:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* 5. MAIN CONTENT AREA */
.wrapper {
    display: flex;
}

/* assets/css/style.css */

/* Updated Main Content for Sticky Footer */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 25px;
    transition: all 0.3s ease;
    /* NEW: Flex layout to push footer down */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* NEW: This forces the content to grow and push the footer to the bottom */
.content-body {
    flex-grow: 1;
}

/* Top Bar */
.top-bar {
    background: var(--card-bg);
    padding: 15px 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.user-info span {
    margin-right: 10px;
}

/* 6. CARDS & DASHBOARD */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    /* Smoother corners */
    border: none;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    /* Lift effect */
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: white;
    padding: 20px 25px;
    font-weight: 600;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
}

.card-body {
    padding: 25px;
}

/* Dashboard Stat Cards - Colored Borders are boring, let's do Icons/Gradients */
/* Note: You might need to add icons to your HTML later, but this styles the existing blocks */

/* 7. TABLES - Clean & Airy */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table th {
    background: #f8fafc;
    color: #4a5568;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 15px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background-color: #f7fafc;
}

/* 8. BUTTONS - Gradients & Shadows */
.btn {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-success {
    background: var(--secondary-gradient);
    color: white;
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* 9. FORMS - Modern Inputs */
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    /* Thicker border */
    border-radius: 8px;
    background: #f9fafb;
    font-family: inherit;
    transition: all 0.3s;
}

.form-control:focus {
    background: white;
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-label {
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 8px;
    display: block;
}

/* 10. LOGIN PAGE - Glassmorphism */
.login-container {
    background: url('https://images.unsplash.com/photo-1497366216548-37526070297c?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80');
    /* Professional Office BG */
    background-size: cover;
    background-position: center;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    /* High opacity for readability */
    backdrop-filter: blur(10px);
    /* Glass effect */
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    width: 450px;
    animation: fadeIn 0.8s ease-out;
}

/* Badges */
.badge {
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #c6f6d5;
    color: #22543d;
}

.badge-danger {
    background: #fed7d7;
    color: #822727;
}

.badge-warning {
    background: #feebc8;
    color: #744210;
}

/* assets/css/style.css - Add to bottom */

/* Fix for Table Inputs (Invoice Page) */
.table input.form-control,
.table select.form-control {
    min-width: 80px;
    /* Prevents quantity from being hidden */
    padding: 8px;
    /* Adjust padding for smaller spaces */
    height: 40px;
    /* Consistent height */
}

/* specific fix for product dropdown to be wider */
.table select.form-control {
    min-width: 200px;
}

/* --- ADD THIS TO THE BOTTOM OF assets/css/style.css --- */

/* DESKTOP DEFAULT: Hide Hamburger Menu */
.hamburger-menu {
    display: none; /* Hidden by default on large screens */
}

/* RESPONSIVE LAYOUT (Mobile & Tablet) */
@media (max-width: 992px) {

    /* 1. Sidebar: Hide it off-screen by default */
    .sidebar {
        left: -260px;
        /* Move completely out of view */
        box-shadow: none;
        transition: all 0.3s ease-in-out;
    }

    /* 2. Active Sidebar: Slide it back in when button is clicked */
    .sidebar.active {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
        /* Strong shadow for "overlay" feel */
    }

    /* 3. Main Content: Expand to full screen width */
    .main-content {
        margin-left: 0 !important;
        /* Remove the gap for the sidebar */
        width: 100% !important;
        padding: 15px;
        /* Smaller padding for mobile */
    }
    
    /* 1. Show Hamburger on Mobile */
    .hamburger-menu {
        display: block !important;
        font-size: 1.4rem;
        color: var(--text-dark);
        cursor: pointer;
        padding: 5px;
        margin-right: 15px;
    }

    /* 2. Hide User Info Text on Mobile (Only show Icon) */
    .user-info .hide-mobile {
        display: none !important;
    }
    
    /* 3. Adjust Title Size */
    .page-info h3 {
        font-size: 1.1rem;
    }

    /* 5. Top Bar adjustments */
    .top-bar {
        padding: 10px 15px;
        position: sticky;
        /* Keep navbar at top while scrolling */
        top: 0;
        z-index: 900;
    }

    .page-info h3 {
        font-size: 1.1rem;
        /* Smaller title font */
    }

    /* 6. Fix for Tables (Horizontal Scroll) */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iPhone */
        display: block;
        width: 100%;
    }

    /* 7. Form Inputs */
    .card-body {
        padding: 20px 15px;
        /* Less padding inside cards */
    }

    .form-group {
        margin-bottom: 15px;
    }
}

/* SMALLER PHONES (iPhone SE, etc) */
@media (max-width: 480px) {

    .user-info .name,
    .user-info .role {
        display: none;
        /* Hide name/role to save space */
    }

    .top-bar {
        justify-content: space-between;
    }
}

/* Mini "Add New" Button for Forms */
.btn-mini-add {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    background-color: rgba(106, 17, 203, 0.1);
    /* Light Purple BG */
    padding: 4px 12px;
    border-radius: 50px;
    /* Pill Shape */
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-mini-add:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(106, 17, 203, 0.3);
    text-decoration: none;
}

/* --- Table Alignment Utilities --- */
.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

/* Professional Table Widths */
.table th:first-child {
    width: 80px;
    /* Fixed width for ID column */
}

.table th:last-child {
    width: 200px;
    /* Fixed width for Action column so buttons fit */
    text-align: right;
}

/* Fix for Long Descriptions */
.col-desc {
    max-width: 250px;
    /* Limits width */
    min-width: 200px;
    white-space: normal;
    /* Forces text to wrap */
    word-wrap: break-word;
}

.read-more-btn {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    margin-left: 5px;
}

.read-more-btn:hover {
    text-decoration: underline;
}

/* --- Table Alignment Utilities (FORCE CENTER EVERYTHING) --- */

/* 1. Global Table Centering */
.table th,
.table td {
    text-align: center !important;
    /* Forces everything to the center */
    vertical-align: middle;
    /* Centers content vertically */
    padding: 12px 15px;
}

/* 2. Override existing directional classes */
/* Even if the HTML says "text-right", we force it to center */
.text-right,
th.text-right,
td.text-right {
    text-align: center !important;
}

.text-left,
th.text-left,
td.text-left {
    text-align: center !important;
}

/* 3. Action Column (Buttons) */
.table th:last-child,
.table td:last-child {
    text-align: center !important;
    width: 180px;
    white-space: nowrap;
}

/* 4. ID Column (First Column) */
.table th:first-child,
.table td:first-child {
    text-align: center !important;
    width: 80px;
}

/* --- Responsive Grid for Categories --- */
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 2fr; /* Left card smaller, Right card wider */
    gap: 25px;
    align-items: start;
}

/* Mobile Layout */
@media (max-width: 992px) {
    .dashboard-grid-2 {
        grid-template-columns: 1fr; /* Stack them vertically */
    }
    
    /* Ensure the 'Add Category' card doesn't stretch weirdly */
    .card {
        height: auto !important;
    }
}

/* --- Billing Details Layout --- */
.row-flex {
    display: flex;
    gap: 20px;
}

/* --- RESPONSIVE INVOICE TABLE (Mobile Cards) --- */
@media (max-width: 768px) {
    
    /* 1. Stack Billing Details */
    .row-flex {
        flex-direction: column;
        gap: 15px;
    }

    /* 2. Hide Table Headers */
    #invoiceTable thead {
        display: none;
    }

    /* 3. Make Rows look like Cards */
    #invoiceTable tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e3e6f0;
        border-radius: 10px;
        margin-bottom: 20px;
        padding: 15px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    }

    /* 4. Make Cells Stack Vertically */
    #invoiceTable td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #f1f1f1;
        padding: 10px 0;
        text-align: right;
    }

    #invoiceTable td:last-child {
        border-bottom: none;
        justify-content: flex-end;
    }

    /* 5. Add Labels before content using data-label */
    #invoiceTable td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-color);
        text-align: left;
        margin-right: 15px;
        width: 40%; /* Keep labels aligned */
    }

    /* 6. Adjust Input Widths */
    #invoiceTable .form-control {
        width: 100% !important; /* Let inputs take remaining space */
        text-align: right;
    }
    
    /* 7. Fix Select2 Width on Mobile */
    .select2-container {
        width: 100% !important;
    }
    
    /* 8. Align Grand Total Section */
    .card-body {
        padding: 15px;
    }
}

/* Hide Hamburger on Desktop */
.hamburger-menu {
    display: none;
}

/* --- HAMBURGER & MODULE ICON TOGGLE --- */

/* Desktop: Show module icon, hide hamburger (icon is decorative, not clickable) */
@media (min-width: 993px) {
    .hamburger-icon {
        display: none !important;
    }
    
    .module-icon {
        display: inline-block !important;
    }
    
    .hamburger-menu {
        display: block !important;
        cursor: default !important; /* Not clickable on desktop */
        pointer-events: none; /* Disable clicking */
    }
}

/* Mobile/Tablet: Show hamburger, hide module icon (clickable to toggle sidebar) */
@media (max-width: 992px) {
    .hamburger-icon {
        display: inline-block !important;
    }
    
    .module-icon {
        display: none !important;
    }
    
    .hamburger-menu {
        display: block !important;
        cursor: pointer !important;
        pointer-events: auto; /* Enable clicking */
    }
}

/* --- Lightbox / Image Zoom Styles --- */

/* Thumbnail in Table */
.product-thumbnail {
    width: 50px; 
    height: 50px; 
    object-fit: cover; 
    border-radius: 4px; 
    border: 1px solid #eee;
    cursor: pointer;
    transition: transform 0.2s;
}
.product-thumbnail:hover {
    transform: scale(1.1); /* Slight zoom on hover */
    border-color: var(--primary-color);
}

/* The Full Screen Popup */
.lightbox {
    display: none; /* Hidden by default */
    position: fixed; 
    z-index: 2000; /* Sit on top of everything */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.85); /* Dark transparent background */
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

/* The Image Inside Popup */
.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s;
}

/* Close Button (X) */
.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.close-lightbox:hover { color: #ccc; }

@keyframes zoomIn {
    from {transform:scale(0.8); opacity: 0;} 
    to {transform:scale(1); opacity: 1;}
}

/* --- Product Image Thumbnail (Fixes Broken Layout) --- */
.product-thumbnail {
    width: 50px;       /* Forces small width */
    height: 50px;      /* Forces small height */
    object-fit: cover; /* Crops image neatly to fit the square */
    border-radius: 4px; 
    border: 1px solid #eee;
    cursor: pointer;
    transition: transform 0.2s;
}

.product-thumbnail:hover {
    transform: scale(1.1); /* Slight zoom effect on hover */
    border-color: var(--primary-color);
}

/* --- Lightbox / Full Screen Popup (If you added the popup code) --- */
.lightbox {
    display: none;
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.85); 
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* --- TABS DESIGN --- */
.tab-container {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
    gap: 20px;
    overflow-x: auto;
}

.tab-btn-main {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab-btn-main:hover { color: var(--primary-color); }

.tab-btn-main.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content-panel {
    display: none;
    animation: fadeIn 0.3s;
}
.tab-content-panel.active { display: block; }

/* --- VISUAL TIMELINE DESIGN --- */
.timeline {
    position: relative;
    padding-left: 30px;
    margin-top: 20px;
    border-left: 2px solid #e2e8f0;
}

.timeline-item {
    position: relative;
    margin-bottom: 25px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -36px; /* Adjust to sit on the line */
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--primary-color);
}

/* Color code timeline dots */
.timeline-item.return::before { border-color: var(--success-color); }
.timeline-item.sold::before { border-color: var(--warning-color); }
.timeline-item.damage::before { border-color: var(--danger-color); }
.timeline-item.start::before { border-color: var(--primary-color); }

.timeline-date {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
}

.timeline-content {
    font-weight: 600;
    font-size: 1rem;
    color: #333;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-dark);
    border: 1px solid #cbd5e0;
}
.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* --- Fix Mobile Table & Badge Layout --- */

/* 1. Fix Badges (Status & Breakdown) */
.badge {
    white-space: nowrap !important; /* Prevents "IN STOCK" from breaking into two lines */
    display: inline-block;
    margin: 2px 1px; /* Adds a tiny gap between the R/S/D badges */
    vertical-align: middle;
}

/* 2. Fix Table Squeezing */
/* This forces the table to keep its width and trigger the scrollbar, 
   instead of squashing columns until they break. */
.table th, .table td {
    white-space: nowrap; /* Keeps content on one line */
}

/* 3. Exception: Allow Product/Customer Names to wrap if they are long */
/* Usually the 2nd column is the Name column */
.table td:nth-child(2) {
    white-space: normal;
    min-width: 140px; /* Ensures the name column doesn't get too thin */
}

/* 4. Mobile Table Container */
/* Ensures the scrollbar appears smoothly on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
}