/* assets/css/style.css - Robust Responsive Fixes */

:root {
    --bg-body: #f3f4f6;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    --acc-success: #10b981;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 
   -----------------------------
   DESKTOP DEFAULT (Min-width 992px) 
   -----------------------------
*/
/* 
   -----------------------------
   DESKTOP DEFAULT (Min-width 992px) 
   -----------------------------
*/
.app-container {
    display: flex;
    /* Switched to Flexbox for stability */
    align-items: flex-start;
    min-height: 100vh;
}

.app-container.collapsed .sidebar {
    width: 80px;
    min-width: 80px;
}

/* Sidebar Base Styles */
.sidebar {
    background: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: 24px 18px; /* Bigger padding */
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;

    /* Flexbox Props */
    width: 280px; /* Wider sidebar */
    min-width: 280px;
    flex-shrink: 0;

    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Chrome Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.brand {
    font-size: 22px; /* Bigger Brand */
    font-weight: 800;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08); /* More subtle border */
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px; /* More gap */
    flex: 1;
    /* Pushes logout down */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px; /* Bigger gap */
    padding: 14px 18px; /* Bigger touch targets */
    color: #cbd5e1; /* Lighter unselected color */
    text-decoration: none;
    border-radius: 10px; /* Softer corners */
    font-weight: 600; /* Bolder text */
    font-size: 15px; /* Bigger text */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
    background: var(--primary);
    color: white;
    transform: translateX(4px); /* Slight slide effect */
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2); /* Shadow on active */
}

.nav-item i {
    width: 28px; /* Bigger icon container */
    text-align: center;
    font-size: 20px; /* Bigger icons */
}

/* Logout Button Special Style */
.nav-item.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
    margin-top: 10px;
    font-weight: 600;
}

/* Logout Button Hover Removed */

/* Desktop Collapse Helpers */
.app-container.collapsed .sidebar .brand span,
.app-container.collapsed .sidebar .nav-item span {
    display: none;
}

.app-container.collapsed .sidebar .brand {
    justify-content: center;
    padding: 20px 0;
}

.app-container.collapsed .sidebar .nav-item {
    justify-content: center;
    padding: 12px;
}

/* Main Content Base */
.main-content {
    flex-grow: 1;
    width: calc(100% - 260px);
    /* Ensure accurate width calc */
    padding: 25px;
    background: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0 !important;
}

/* Standard Header Bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
    flex-wrap: wrap;
}

.header-title-container h1 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Dashboard Grids */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    /* Responsive */
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin: 8px 0;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.charts-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

/* POS Layout */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    height: calc(100vh - 100px);
}

.product-section,
.cart-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.service-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.service-item-modern {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    text-align: center;
}

.modal-sm {
    max-width: 350px !important;
}

/* 
   -----------------------------
   MOBILE & TABLET PORTRAIT (< 992px)
   -----------------------------
*/
@media (max-width: 991px) {

    .app-container,
    .app-container.collapsed {
        display: block !important;
        /* Stack layout, disable Desktop Flex */
        position: relative;
    }

    /* Off-Canvas Sidebar */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 3000;
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.3);
        transition: left 0.3s ease-in-out;
        overflow-y: auto;
        /* Reset Flex props for Mobile */
        flex-shrink: 1;
    }

    .app-container.show-sidebar .sidebar {
        left: 0 !important;
    }

    /* Logout Button in Mobile Sidebar */
    .app-container.show-sidebar .sidebar .nav-item span {
        display: inline;
        /* Ensure text creates width */
    }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 2999;
        backdrop-filter: blur(2px);
    }

    .app-container.show-sidebar .sidebar-overlay {
        display: block;
    }

    /* Adjust Content */
    .main-content {
        width: 100% !important;
        /* Full width */
        padding: 15px !important;
        padding-top: 70px !important;
        margin-left: 0 !important;
    }

    .header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .header-actions {
        justify-content: space-between;
    }

    /* Grids */
    .charts-container {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        /* Disable grid */
        gap: 20px;
    }

    .chart-card {
        width: 100%;
        overflow: hidden;
        /* Prevent canvas overflow */
    }

    /* POS Mobile */
    .pos-layout {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
    }

    .cart-section {
        order: -1;
        max-height: none !important;
        margin-bottom: 20px;
    }

    .product-section {
        height: auto !important;
    }
}

/* 
   -----------------------------
   SMALL MOBILE (< 576px)
   -----------------------------
*/
@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 per row */
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
        /* Compact padding */
    }

    .stat-value {
        font-size: 18px;
        /* Smaller font on mobile */
    }

    .service-grid-modern {
        grid-template-columns: repeat(2, 1fr);
    }

    .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 5px;
    }

    /* Fix table overflow */
    .card-list {
        overflow-x: auto;
    }

    .pos-btn-group {
        overflow-x: auto;
        padding-bottom: 5px;
        justify-content: flex-start;
    }
}

/* Shared UI */
.mobile-nav {
    display: none;
}

@media (max-width: 991px) {
    .mobile-nav {
        display: flex !important;
    }
}

/* Table Scroll */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    min-width: 600px;
}

/* UI Elements: Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-delete {
    background: #fee2e2;
    color: #ef4444;
}

.btn-delete:hover {
    background: #fecaca;
}

/* UI Elements: Forms */
.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: 0.2s;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Select Arrow */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 30px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* POS Category Bar */
.category-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 12px;
    background: white;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    scrollbar-width: thin;
}

.cat-pill {
    padding: 8px 16px;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    user-select: none;
}

.cat-pill:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.cat-pill.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

/* Premium Table Styles */
.card-list {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
}

.styled-table thead tr {
    background-color: #f8fafc;
    border-bottom: 2px solid var(--border);
}

.styled-table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-align: left;
}

.styled-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s;
}

.styled-table tbody tr:hover {
    background-color: #f8fafc;
}

.styled-table td {
    padding: 12px 16px;
    vertical-align: middle;
    color: var(--text-main);
    font-size: 14px;
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef9c3;
    color: #854d0e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* POS Header Layout System */
.pos-header-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* Added slight shadow */
}

/* Left: Title + Buttons */
.pos-left-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    /* Takes available space */
    min-width: 0;
    /* Important for flex child scrolling */
    overflow: hidden;
}

/* Scrollable Button Group */
.pos-btn-group-scrollable {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar */
    padding-bottom: 2px;
}

.pos-btn-group-scrollable::-webkit-scrollbar {
    display: none;
}

/* Right: Search + Clock */
.pos-right-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search Container */
.pos-search-box {
    position: relative;
    width: 250px;
}

/* Mobile Media Query for POS Header */
@media (max-width: 991px) {
    .pos-header-layout {
        flex-wrap: wrap;
        /* Allow wrapping */
        padding: 8px 4px;
        /* Tighter padding */
    }

    .pos-left-section {
        flex-basis: 100%;
        /* Full width first row */
        margin-bottom: 8px;
        /* Space before search */
    }

    .pos-right-section {
        width: 100%;
        justify-content: space-between;
    }

    .pos-search-box {
        width: 100%;
        /* Full width search on mobile */
        order: 2;
        /* Search goes below */
    }

    .clock-widget {
        display: none;
        /* Often hide clock on mobile to save space or move it */
    }

    /* If user wants clock visible, we can put it in title row? 
       Actually user asked for search on 2nd line. 
       Let's put Search on 2nd line (width 100%).
    */
    .pos-right-section {
        flex-basis: 100%;
        display: block;
        /* Stack search */
    }
}

.btn-icon-edit {
    background: #e0f2fe;
    color: #0284c7;
}

.btn-icon-edit:hover {
    background: #bae6fd;
}

.btn-icon-delete {
    background: #fee2e2;
    color: #ef4444;
}

.btn-icon-delete:hover {
    background: #fecaca;
}

.btn-icon-view {
    background: #f3f4f6;
    color: #475569;
}

.btn-icon-view:hover {
    background: #e2e8f0;
}

/* Mobile Utility Helpers */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .hide-mobile-text {
        display: none !important;
    }

    .pos-header-btn i {
        margin: 0 !important;
        font-size: 16px !important;
    }

    .pos-header-btn {
        padding: 8px 10px !important;
    }
}