/* ============================================
   AM FRUTAS Y VERDURAS - ESTILOS MOBILE-FIRST
   ============================================ */

/* ============================================
   VARIABLES DE COLOR
   ============================================ */
:root {
    --verde-oscuro: #2E7D32;
    --verde-oscuro-hover: #1B5E20;
    --verde-claro: #4CAF50;
    --verde-claro-hover: #388E3C;
    --verde-menta: #C8E6C9;
    --verde-menta-claro: #E8F5E9;
    --amarillo: #F9A825;
    --amarillo-hover: #F57F17;
    --blanco: #FFFFFF;
    --gris-claro: #F5F7FA;
    --gris-medio: #9CA3AF;
    --gris-oscuro: #374151;
    --negro: #1A1A1A;
    --sombra-suave: 0 2px 8px rgba(0, 0, 0, 0.08);
    --sombra-media: 0 4px 16px rgba(0, 0, 0, 0.12);
    --sombra-fuerte: 0 8px 32px rgba(0, 0, 0, 0.2);
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 0px;
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--verde-oscuro) 0%, var(--verde-claro) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LOGIN (mobile-first)
   ============================================ */
.container-login {
    width: 100%;
    max-width: 400px;
    padding: 16px;
    animation: fadeInUp 0.5s ease-out;
    margin: 0 auto;
}

.login-card {
    background: var(--blanco);
    border-radius: var(--border-radius);
    padding: 32px 24px 28px;
    box-shadow: var(--sombra-fuerte);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo-login {
    max-width: 120px;
    height: auto;
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-header h1 {
    font-size: 1.4rem;
    color: var(--verde-oscuro);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.login-header .subtitulo {
    color: var(--gris-medio);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 2px;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gris-oscuro);
    margin-bottom: 4px;
    font-size: 0.85rem;
    letter-spacing: 0.2px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #E5E7EB;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: all 0.25s ease;
    background: var(--blanco);
    color: var(--gris-oscuro);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--verde-claro);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.12);
}

.form-group input::placeholder {
    color: #BDBDBD;
}

.form-group small {
    display: block;
    color: var(--gris-medio);
    font-size: 0.75rem;
    margin-top: 4px;
}

/* ============================================
   BOTONES
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--verde-claro) 0%, var(--verde-oscuro) 100%);
    color: var(--blanco);
    font-family: inherit;
    letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.35);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
}

.btn-inicializar {
    background: linear-gradient(135deg, var(--amarillo) 0%, #F57F17 100%);
}

.btn-inicializar:hover:not(:disabled) {
    box-shadow: 0 8px 20px rgba(249, 168, 37, 0.4);
}

/* ============================================
   MENSAJES
   ============================================ */
.mensaje {
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    margin-top: 12px;
    display: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.mensaje-success {
    background: var(--verde-menta-claro);
    color: var(--verde-oscuro);
    border-left: 4px solid var(--verde-claro);
    display: block;
}

.mensaje-error {
    background: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid #EF4444;
    display: block;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--blanco);
    border-radius: var(--border-radius);
    padding: 32px 24px 28px;
    max-width: 440px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease-out;
    position: relative;
    box-shadow: var(--sombra-fuerte);
}

.modal-content::-webkit-scrollbar {
    width: 4px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--gris-claro);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--verde-claro);
    border-radius: 10px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--gris-medio);
    transition: all 0.2s;
    background: none;
    border: none;
    font-family: inherit;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gris-oscuro);
    transform: rotate(90deg);
}

.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-logo {
    max-width: 72px;
    height: auto;
    margin-bottom: 10px;
}

.modal-header h2 {
    color: var(--verde-oscuro);
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-header p {
    color: var(--gris-medio);
    font-size: 0.9rem;
    margin-top: 2px;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ============================================
   DASHBOARD - LAYOUT
   ============================================ */
.dashboard-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    background: var(--gris-claro);
}

/* ============================================
   HEADER
   ============================================ */
.dashboard-header {
    background: var(--blanco);
    padding: 0 16px;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--sombra-suave);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--verde-menta);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Botón hamburguesa */
.btn-hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-hamburger:hover {
    background: var(--verde-menta-claro);
}

.btn-hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--gris-oscuro);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.btn-hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.btn-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.btn-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--verde-oscuro);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--gris-oscuro);
    font-size: 0.85rem;
    display: none;
}

.user-name-mobile {
    font-weight: 600;
    color: var(--gris-oscuro);
    font-size: 0.85rem;
    display: inline;
}

.btn-logout {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: #FEE2E2;
    color: #DC2626;
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-logout:hover {
    background: #FECACA;
}

/* ============================================
   BODY - SIDEBAR + MAIN
   ============================================ */
.dashboard-body {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    position: relative;
}

/* ============================================
   SIDEBAR (mobile-first: oculto por defecto)
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--header-height));
    background: var(--blanco);
    border-right: 1px solid #E5E7EB;
    padding: 12px 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: var(--sombra-media);
}

.sidebar.open {
    transform: translateX(0);
}

/* Overlay para móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
}

.sidebar-overlay.active {
    display: block;
}

/* Scroll del sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--gris-claro);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--verde-claro);
    border-radius: 10px;
}

/* ============================================
   MENÚ (sin emojis, solo texto)
   ============================================ */
.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    border-bottom: 1px solid #F3F4F6;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-toggle {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--gris-oscuro);
    transition: all 0.2s;
    gap: 10px;
    font-size: 0.9rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.menu-toggle:hover {
    background: var(--verde-menta-claro);
    color: var(--verde-oscuro);
}

.menu-toggle .menu-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.menu-toggle::after {
    content: '▸';
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.25s;
    color: var(--gris-medio);
}

.menu-item.open .menu-toggle::after {
    transform: rotate(90deg);
}

/* Submenús */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #FAFAFA;
}

.menu-item.open .submenu {
    max-height: 800px;
}

.submenu-item {
    border-bottom: 1px solid #F3F4F6;
}

.submenu-item:last-child {
    border-bottom: none;
}

.submenu-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px 10px 50px;
    color: var(--gris-oscuro);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.submenu-item a .submenu-icon {
    font-size: 0.9rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.submenu-item a:hover {
    background: var(--verde-menta);
    color: var(--verde-oscuro);
    border-left-color: var(--verde-claro);
}

.submenu-item.active a {
    background: var(--verde-menta-claro);
    color: var(--verde-oscuro);
    font-weight: 600;
    border-left-color: var(--verde-claro);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--gris-claro);
    width: 100%;
    min-height: calc(100vh - var(--header-height));
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--blanco);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--sombra-suave);
    border-left: 4px solid var(--verde-claro);
}

.stat-icon {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--verde-menta-claro);
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 0.7rem;
    color: var(--gris-medio);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--verde-oscuro);
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
    background: var(--blanco);
    border-radius: var(--border-radius-sm);
    padding: 16px 18px;
    box-shadow: var(--sombra-suave);
}

.quick-actions h3 {
    color: var(--gris-oscuro);
    font-size: 0.9rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    padding: 8px 16px;
    border: 2px solid var(--verde-menta);
    border-radius: var(--border-radius-sm);
    background: var(--blanco);
    color: var(--verde-oscuro);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.82rem;
    font-family: inherit;
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.btn-action:hover {
    background: var(--verde-claro);
    color: var(--blanco);
    border-color: var(--verde-claro);
}

/* ============================================
   TABLAS
   ============================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 500px;
}

.table thead {
    background: var(--verde-menta-claro);
}

.table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--verde-oscuro);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #F3F4F6;
    color: var(--gris-oscuro);
}

.table tbody tr:hover {
    background: #FAFAFA;
}

/* Badges */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}

.badge-entregado {
    background: #D1FAE5;
    color: #065F46;
}

.badge-pendiente {
    background: #FEF3C7;
    color: #92400E;
}

.badge-cancelado {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-confirmado {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-contado {
    background: #D1FAE5;
    color: #065F46;
}

.badge-cuenta-corriente {
    background: #DBEAFE;
    color: #1E40AF;
}

/* ============================================
   CARDS Y PÁGINAS
   ============================================ */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.page-header h2 {
    color: var(--verde-oscuro);
    font-size: 1.2rem;
    font-weight: 700;
}

.page-header p {
    color: var(--gris-medio);
    font-size: 0.85rem;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.card {
    background: var(--blanco);
    border-radius: var(--border-radius-sm);
    padding: 18px;
    box-shadow: var(--sombra-suave);
    margin-bottom: 16px;
}

.card h3 {
    color: var(--gris-oscuro);
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.welcome-card {
    background: var(--blanco);
    border-radius: var(--border-radius);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--sombra-suave);
    max-width: 500px;
    margin: 20px auto;
}

.welcome-card h2 {
    color: var(--verde-oscuro);
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.welcome-card p {
    color: var(--gris-medio);
    font-size: 0.9rem;
}

/* ============================================
   ICONOS VECTORIALES (SVG inline)
   ============================================ */
.icon-dashboard {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon-dashboard svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* ============================================
   RESPONSIVE - TABLET (768px+)
   ============================================ */
@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .main-content {
        padding: 24px 32px;
    }

    .user-name {
        display: inline;
    }

    .user-name-mobile {
        display: none;
    }

    .btn-hamburger {
        display: none;
    }

    .sidebar {
        position: sticky;
        top: var(--header-height);
        transform: translateX(0);
        width: var(--sidebar-width);
        height: calc(100vh - var(--header-height));
        box-shadow: none;
        flex-shrink: 0;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .header-actions {
        margin-top: 0;
    }

    .btn-action {
        flex: none;
        min-width: auto;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .dashboard-body {
        min-height: calc(100vh - var(--header-height));
    }

    .main-content {
        padding: 32px 40px;
        min-height: calc(100vh - var(--header-height));
    }

    .dashboard-grid {
        gap: 20px;
    }

    .stat-card {
        padding: 24px 28px;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .header-title {
        font-size: 1.1rem;
    }

    .sidebar {
        width: var(--sidebar-width);
    }

    .login-card {
        padding: 40px 36px 32px;
    }
}

/* ============================================
   RESPONSIVE - MÓVIL PEQUEÑO (hasta 380px)
   ============================================ */
@media (max-width: 380px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px 16px 20px;
    }

    .modal-content {
        padding: 24px 16px 20px;
    }

    .header-title {
        font-size: 0.8rem;
    }

    .header-logo {
        height: 26px;
    }

    .btn-logout {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .stat-card {
        padding: 12px 14px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .main-content {
        padding: 12px;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */
.text-muted {
    color: var(--gris-medio);
}

.text-center {
    text-align: center;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

.empty-message {
    text-align: center;
    color: var(--gris-medio);
    padding: 24px;
    font-size: 0.9rem;
}

.error-message {
    text-align: center;
    color: #DC2626;
    padding: 20px;
}

.construction {
    text-align: center;
    padding: 32px 16px;
}

.construction-icon {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 12px;
}

.construction h3 {
    color: var(--gris-oscuro);
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.construction p {
    color: var(--gris-medio);
    font-size: 0.9rem;
}

/* ============================================
   OVERLAY PARA CUANDO EL SIDEBAR ESTÁ ABIERTO
   ============================================ */
body.sidebar-open {
    overflow: hidden;
}