@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Desayunos Deli Brand Colors */
    --primary: #7C3AED;
    /* Morado profundo - transmite emoción, cercanía y sensación premium */
    --primary-light: #A78BFA;
    /* Morado suave */
    --primary-dark: #5B21B6;
    /* Morado oscuro */
    --secondary: #F9A8D4;
    /* Rosa pastel - apoyo visual y sensación cálida */
    --accent: #FCD34D;
    /* Amarillo cálido - detalles y acentos importantes */
    --bg-dark: #0F172A;
    /* Fondo oscuro principal */
    --bg-card: rgba(30, 41, 59, 0.7);
    /* Tarjetas con transparencia */
    --bg-sidebar: #1E293B;
    /* Barra lateral */
    --text-main: #F8FAFC;
    /* Texto principal - blanco limpio */
    --text-muted: #CBD5E1;
    /* Texto secundario - gris claro */
    --border: rgba(255, 255, 255, 0.1);
    /* Bordes sutiles */
    --glass-grad: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));

    /* Spacing & Borders */
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);
    /* Glow morado */
    /* Glow morado */
}

/* Login Gate Styling */
.login-gate {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 3rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

body {
    font-family: 'Poppins', sans-serif;
    /* Sans serif moderna con formas redondeadas */
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

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

/* Sidebar */
aside.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    z-index: 10;
}

.logo-container {
    padding: 0 1rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

nav.main-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--glass-grad);
    color: var(--text-main);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.nav-item i {
    font-size: 1.25rem;
}

/* Main Content Area */
main.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    background: radial-gradient(circle at top right, rgba(109, 40, 217, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(244, 114, 182, 0.1), transparent 40%);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.welcome-msg h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.welcome-msg p {
    color: var(--text-muted);
}

/* Glass Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
}

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

/* Stats Badges */
.stats-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.85rem;
}

.badge-success {
    background: rgba(45, 212, 191, 0.1);
    color: var(--accent);
}

.badge-warning {
    background: rgba(244, 114, 182, 0.1);
    color: var(--secondary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all 0.3s ease;
}

.actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control-sm {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    padding-right: 45px;
    /* Significant space for native icons */
    min-width: 180px;
    /* Generous width for long months like 'September' or 'February' */
    text-align: left;
}

/* Fix for native calendar indicators on mobile */
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.8);
    /* Make it more visible on dark theme */
    position: absolute;
    right: 10px;
}

/* Custom Calendar Input */
input[type="date"],
input[type="month"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;

    /* Force Native Picker to Dark Mode */
    color-scheme: dark;

    /* Custom Icon via Background */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232DD4BF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

/* Hide Default Indicator but keep it clickable */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

input[type="date"]:hover,
input[type="date"]:focus,
input[type="month"]:hover,
input[type="month"]:focus {
    border-color: var(--accent);
    background-color: rgba(45, 212, 191, 0.05);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.1);
    outline: none;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: white;
    font-family: inherit;
    transition: all 0.3s ease;
}

/* Extra padding for select elements to avoid arrow overlap */
select.form-control {
    padding-right: 3rem;
    background-position: right 0.75rem center;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.2);
}

/* Toggle Group / Segmented Control */
.toggle-group {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}

.toggle-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: calc(var(--radius-md) - 4px);
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

.toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

.animate-slide-down {
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.big-stat {
    font-size: 2.2rem;
    /* Slightly smaller to give more room */
    font-weight: 700;
    margin: 0.8rem 0;
    /* Less margin */
    letter-spacing: -1px;
}

.card-glow {
    position: relative;
    overflow: hidden;
}

.card-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(109, 40, 217, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

/* Progress Indicators */
.progress-container {
    margin-top: 1rem;
    position: relative;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: visible;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 20px;
    background: var(--accent);
    z-index: 5;
    box-shadow: 0 0 10px var(--accent);
}

.marker-label {
    position: absolute;
    top: 22px;
    /* Move BELOW the progress bar */
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 600;
}

.metric-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 1.4rem;
    /* Even more space to push titles up */
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Fulfillment Visualizer */
.fulfillment-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-top: 1.5rem;
    overflow: hidden;
}

.fulfillment-fill {
    height: 100%;
    border-radius: 4px;
    width: 0;
    /* Start at 0 for animation */
    transition: width 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fill-accent {
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

.fill-secondary {
    background: var(--secondary);
    box-shadow: 0 0 15px var(--secondary);
}

@keyframes pulse-glow {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.animate-pulse {
    animation: pulse-glow 2s infinite ease-in-out;
}

.text-accent {
    color: var(--accent);
}

.text-secondary {
    color: var(--secondary);
}

.text-bold {
    font-weight: 700;
}

.dashboard-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* --- Responsive Design --- */

/* Mobile Header & Toggle */
.mobile-header {
    display: none;
    background: var(--bg-sidebar);
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
}

.logo-container-small {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 25;
}

@media (max-width: 1024px) {
    .dashboard-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 850px) {
    body {
        overflow: auto;
    }

    .app-container {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
        padding: 1rem 1.5rem;
        height: 80px;
    }

    aside.sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100dvh;
        overflow-y: auto;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 30;
    }

    aside.sidebar.active {
        transform: translateX(280px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    main.content-area {
        padding: 1.5rem 1.25rem;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .actions {
        width: 100%;
        flex-direction: column;
    }

    .filter-group,
    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .dashboard-summary-grid,
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .big-stat {
        font-size: 1.8rem;
    }

    /* Table Responsiveness */
    .card {
        padding: 1rem;
        overflow-x: auto;
    }

    .data-table {
        min-width: 600px;
        /* Force scroll horizontally on small screens */
    }
}

@media (max-width: 480px) {
    .welcome-msg h1 {
        font-size: 1.5rem;
    }

    .metric-footer {
        flex-direction: column;
        gap: 10px;
    }
}