/* --- Color Variables and Global Resets --- */
:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #00b894; 
    --danger: #ff6b81; 
    --warning: #feca57; 
    --info: #54a0ff;
    --light: #f4f6f9; /* Lighter background for main content */
    --dark: #333;
    --text-muted: #6c757d;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --- 1. Sidebar Styles (Fixed Position & Layout) --- */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff; 
    color: var(--dark);
    display: flex;
    flex-direction: column;
    position: fixed; /* Fixes sidebar on the left */
    height: 100vh;
    z-index: 1000;
    box-shadow: 0 0 15px rgba(0,0,0,0.05); 
    left: 0;
    top: 0;
    border-right: 1px solid #f0f0f0; 
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem; 
    border-bottom: 1px solid #f0f0f0;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.4rem; 
    font-weight: 700;
    color: var(--primary); /* Logo in primary color */
}

.app-logo i {
    font-size: 1.75rem;
    color: var(--primary);
}

.sidebar-menu {
    flex: 1;
    padding: 0.5rem 0.5rem; 
}

.sidebar-menu .nav-link {
    color: var(--text-muted); 
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    text-decoration: none;
    font-weight: 500;
}

.sidebar-menu .nav-link:hover {
    background: var(--light); 
    color: var(--primary); 
}

/* Active Link Style */
.sidebar-menu .nav-link.active {
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 8px rgba(var(--primary), 0.2); 
    font-weight: 600;
}
.sidebar-menu .nav-link.active i {
    color: white; 
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f0f0f0;
}


/* --- 2. Main Content & Dashboard Styles (Layout Fix) --- */
.main-content {
    flex: 1;
    /* FIX: Added margin-left to make space for the fixed sidebar */
    margin-left: var(--sidebar-width); 
    padding: 2.5rem 2rem; 
    min-height: 100vh;
    /* FIX: Ensures content uses the remaining width */
    width: calc(100% - var(--sidebar-width)); 
    background-color: var(--light); 
}

.page-title {
    font-size: 2rem; 
    font-weight: 800;
    color: var(--dark);
    margin: 0;
}

/* Card Styles */
.card {
    border: none;
    border-radius: 1.25rem; 
    box-shadow: 0 8px 15px rgba(0,0,0,0.08); 
    margin-bottom: 2rem;
    background: white;
    transition: transform 0.3s ease;
}

.card-header {
    background: none; /* Make header background clean white */
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 1.25rem !important; /* Ensure consistent padding */
}

/* FIX: Dashboard Grid Layout */
.stats-grid {
    /* **THIS IS THE CRITICAL FIX for the row/stack issue** */
    display: grid;
    /* 4 columns for desktop */
    grid-template-columns: repeat(4, 1fr); 
    gap: 1.5rem; /* Gap between cards */
    margin-bottom: 2rem;
}

/* Stat Card specific improvements (for the modern look) */
.stat-card {
    border: none;
    padding: 1.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.stat-icon-modern {
    width: 48px;
    height: 48px;
    border-radius: 50%; /* Makes the icon round */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); /* Shadow on icon for depth */
}

.view-details-link:hover {
    color: var(--primary) !important;
}


/* NEW: Utility Classes */
.bg-primary { background-color: var(--primary) !important; }
.bg-success { background-color: var(--success) !important; }
.bg-info { background-color: var(--info) !important; }
.bg-danger { background-color: var(--danger) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-info { color: var(--info) !important; }
.text-danger { color: var(--danger) !important; }


/* --- Responsive Styles --- */
@media (max-width: 1200px) {
    .stats-grid {
        /* 3 columns for medium screens */
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .stats-grid {
        /* 2 columns for tablet */
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        /* Hides sidebar by default on mobile */
        transform: translateX(-100%); 
        width: 100%;
        height: 100%;
    }
    .main-content {
        /* Full width on mobile */
        margin-left: 0;
        width: 100%;
        padding: 1.5rem 1rem;
    }
/* Stat Card specific improvements (for the modern look) */
.stat-card {
    border: none;
    padding: 1.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Main Colors */
:root {
    --primary: #771608;
    --secondary: #3f37c9;
    --success: #00b894;
    --danger: #ff6b81;
    --warning: #feca57;
    --info: #54a0ff;
    --light: #f4f6f9;
    --dark: #333;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light);
    color: var(--dark);
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.app-logo i {
    font-size: 1.8rem;
}

.sidebar-menu {
    padding: 20px 0;
}

.sidebar-menu .nav-link {
    color: #555;
    padding: 12px 20px;
    margin: 5px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu .nav-link:hover {
    background: var(--light);
    color: var(--primary);
}

.sidebar-menu .nav-link.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    position: absolute;
    bottom: 0;
    width: 100%;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: 100vh;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.card-header {
    background: white;
    border-bottom: 1px solid #eee;
    padding: 15px 20px;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}

.stat-icon-modern {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

/* Tables */
.table th {
    font-weight: 600;
    background: #f8f9fa;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* Buttons */
.btn {
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 500;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
/* Touch optimization */
@media (max-width: 768px) {
    .distribution-allocator .row {
        flex-direction: column;
    }
    
    .delivery-sequence .delivery-step {
        flex-direction: column;
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 10px;
        background: #f8f9fa;
    }
    
    .route-stats {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .delivery-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
    }
}

/* Touch-friendly elements */
.delivery-step {
    padding: 15px;
    margin: 8px 0;
    border-radius: 12px;
    background: white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.delivery-step:active {
    transform: scale(0.98);
}

.touch-button {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
}