:root {
    --primary: #001f3f;
    --primary-light: #003366;
    --dark-blue: #001f3f;
    --accent: #ffcc00;
    --accent-hover: #e6b800;
    --yellow: #ffcc00;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #6c757d;
    --text-white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary);
    color: var(--text-white);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transition: var(--transition);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    list-style: none;
}

.menu-item {
    padding: 0.5rem 1.5rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1.2rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
}

.menu-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: var(--text-white);
}

.menu-link.active {
    background-color: var(--accent);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

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

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex children from overflowing */
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-action {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.2rem;
    position: relative;
    transition: var(--transition);
}

.nav-action:hover {
    color: var(--primary);
}

.badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 700;
    border: 2px solid var(--bg-card);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border-radius: 30px;
    background-color: #f0f2f5;
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    background-color: #e4e6e9;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Content Area */
.content-area {
    padding: 2rem;
    flex: 1;
}

/* Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0,0,0,0.05);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 31, 63, 0.2);
}

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

.btn-accent:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 204, 0, 0.2);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--accent);
    color: var(--primary);
}

.btn-outline:hover {
    background-color: var(--accent);
    color: var(--primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h2 {
    font-size: 1.8rem;
    margin: 5px 0;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .mobile-toggle {
        display: block !important;
    }
    .mobile-close {
        display: block !important;
        cursor: pointer;
        font-size: 1.4rem;
        color: var(--accent);
        padding: 5px 10px;
        transition: var(--transition);
    }
    .mobile-close:hover {
        color: var(--text-white);
    }
}

.mobile-close {
    display: none;
}

.mobile-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary);
}

/* Transitions */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

/* Form Validation Styles */
.is-invalid {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}

.is-valid {
    border-color: #16a34a !important;
    background-color: #f0fdf4 !important;
}

.error-feedback {
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
    font-weight: 500;
}

/* ==========================================
   GLOBAL RESPONSIVENESS AND MOBILE FIXES
   ========================================== */

/* 1. Global typography and margin adjustments for smaller screens */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem !important;
    }
    h2 {
        font-size: 1.5rem !important;
    }
    h3 {
        font-size: 1.25rem !important;
    }
    .content-area {
        padding: 1.25rem !important;
    }
}

@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem !important;
    }
    h2 {
        font-size: 1.3rem !important;
    }
    h3 {
        font-size: 1.15rem !important;
    }
    .content-area {
        padding: 0.85rem !important;
    }
}

/* 2. Global Table Responsiveness */
@media (max-width: 768px) {
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* 3. Dynamic overrides for inline styled grids to stack on mobile */
@media (max-width: 992px) {
    div[style*="grid-template-columns: 1fr 2.2fr"],
    .grid[style*="grid-template-columns: 1fr 2.2fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    .grid[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

@media (max-width: 768px) {
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    .grid[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    .grid[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    }
    
    div[style*="grid-template-columns: 1fr 1fr"],
    .grid[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

@media (max-width: 576px) {
    /* Hard stack all 2-column or 3-column elements on small mobile */
    div[style*="grid-template-columns: 1fr 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    div[style*="grid-template-columns: 80px 180px 1fr 140px 140px 30px"],
    .grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* Adapt display flex rows that stretch too wide */
    div[style*="display: flex; justify-content: space-between; align-items: center"],
    div[style*="display: flex; justify-content: space-between; align-items: flex-start"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    div[style*="display: flex; justify-content: space-between; align-items: center"] > div[style*="display: flex"],
    div[style*="display: flex; justify-content: space-between; align-items: flex-start"] > div[style*="display: flex"] {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .btn:not(.page-link):not(.btn-icon):not(.tab-btn),
    form button[type="submit"],
    input[type="submit"] {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* 4. Chat Responsiveness Fix */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column !important;
        height: auto !important;
        min-height: 80vh !important;
    }
    .chat-container > .card:first-child {
        width: 100% !important;
        height: auto !important;
        padding: 10px !important;
    }
    .chat-container > .card:last-child {
        width: 100% !important;
        flex: 1 !important;
        height: 60vh !important;
    }
    #customer-list-ul {
        display: flex !important;
        gap: 10px !important;
        overflow-x: auto !important;
        padding: 5px 0 !important;
        white-space: nowrap !important;
        scrollbar-width: none;
    }
    #customer-list-ul::-webkit-scrollbar {
        display: none;
    }
    #customer-list-ul li {
        margin-bottom: 0 !important;
        flex: 0 0 auto !important;
    }
    .customer-btn {
        width: auto !important;
        padding: 8px 15px !important;
        font-size: 0.85rem !important;
    }
}

/* 5. Mobile header logo/avatar overflow protection */
@media (max-width: 576px) {
    .app-header {
        padding: 0 1rem !important;
    }
    .header-title {
        font-size: 1rem !important;
        max-width: 140px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .user-profile .user-name {
        display: none !important;
    }
    .user-profile {
        padding: 2px !important;
        background: transparent !important;
    }
}

/* 6. Card & Modal responsive paddings */
@media (max-width: 576px) {
    .card {
        padding: 1rem !important;
    }
    
    div[style*="position: fixed;"] > .card,
    .custom-modal-content {
        width: 95% !important;
        margin: 10px auto !important;
        padding: 1.25rem !important;
        max-height: 95vh !important;
    }
}

/* ==========================================
   PRODUCTION TIMELINE RESPONSIVE
   ========================================== */
.production-timeline-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 16px !important;
    height: 5px !important;
    background: #e2e8f0;
    transform: translateY(-50%);
    z-index: 1;
}

.production-timeline-progress {
    position: absolute;
    left: 0;
    width: var(--progress);
    top: 16px !important;
    height: 5px !important;
    background: #22c55e;
    transform: translateY(-50%);
    z-index: 2;
    transition: width 0.3s ease;
}

@media (max-width: 768px) {
    .production-timeline {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 24px !important;
        padding-left: 20px !important;
        margin: 20px 0 !important;
    }
    .production-timeline-line {
        left: 36px !important;
        top: 0 !important;
        bottom: 0 !important;
        right: auto !important;
        width: 5px !important;
        height: 100% !important;
        transform: none !important;
    }
    .production-timeline-progress {
        left: 36px !important;
        top: 0 !important;
        width: 5px !important;
        height: var(--progress) !important;
        right: auto !important;
        transform: none !important;
        transition: height 0.3s ease !important;
    }
    .production-timeline-step {
        flex-direction: row !important;
        text-align: left !important;
        gap: 15px !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }
    .production-timeline-label {
        margin-top: 0 !important;
        font-size: 0.85rem !important;
    }
    
    /* 1fr 1.2fr stacking */
    div[style*="grid-template-columns: 1fr 1.2fr"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Guest header: hide redundant Katalog text on mobile */
@media (max-width: 576px) {
    .app-header .header-right nav ul li:first-child {
        display: none !important;
    }
}

/* Admin/Owner order lists: stack 6-column order-header on tablet/mobile */
@media (max-width: 992px) {
    div[style*="grid-template-columns: 80px 180px 1fr 140px 140px 30px"] {
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 15px !important;
    }
    div[style*="grid-template-columns: 80px 180px 1fr 140px 140px 30px"] > div[style*="border-right"] {
        border-right: none !important;
        padding-right: 0 !important;
        text-align: left !important;
    }
}
@media (max-width: 576px) {
    div[style*="grid-template-columns: 80px 180px 1fr 140px 140px 30px"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}
/* ==========================================
   PAGINATION OVERRIDES
   ========================================== */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    gap: 8px;
    margin: 0;
    justify-content: center;
    flex-wrap: wrap;
}
.page-item .page-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
    background-color: var(--bg-card);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.page-item:not(.disabled) .page-link:hover {
    background-color: #f0f2f5;
    color: var(--primary-light);
    border-color: rgba(0,0,0,0.2);
}
.page-item.active .page-link {
    background-color: var(--accent);
    color: var(--primary);
    border-color: var(--accent);
    font-weight: 600;
}
.page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    background-color: #f8f9fa;
    border-color: rgba(0,0,0,0.05);
}
