:root {
    /* Paleta Modo Oscuro - Azul & Naranja */
    --primary: #4fc3f7;       /* Azul claro para iconos y realces */
    --primary-dark: #0d47a1;  /* Azul marino profundo para Sidebar */
    --accent: #ff9800;        /* Naranja vibrante para botones */
    --accent-hover: #f57c00;
    
    --bg-body: #121212;       /* Fondo general negro mate */
    --bg-card: #1e252b;       /* Gris azulado muy oscuro para tarjetas */
    --text-main: #e0e6ed;     /* Blanco azulado para lectura */
    --text-muted: #90a4ae;    /* Gris para etiquetas secundarias */
    --border-color: #2c3e50;  /* Bordes sutiles azulados */
    /* Más contraste para filas alternas (zebra) */
    --table-row-odd: rgba(255,255,255,0.02);
    --table-row-even: rgba(255,255,255,0.06);
    --table-row-hover: rgba(79,195,247,0.12);
    
    --sidebar-width: 280px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    display: flex;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* --- CABECERA MÓVIL --- */
#mobile-header {
    display: none;
    background: var(--primary-dark);
    color: white;
    padding: 15px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1001;
    box-sizing: border-box;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.4);
    z-index: 1002;
    transition: var(--transition);
}

.sidebar-header {
    padding: 30px 20px;
    background: rgba(0,0,0,0.2);
    text-align: center;
    font-weight: bold;
    font-size: 1.3em;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
}

.menu-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.menu-group { margin-bottom: 25px; }

.group-title {
    display: block;
    padding: 10px 25px 5px;
    font-size: 0.7rem;
    color: var(--primary); /* Azul claro */
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
}

.group-title.collapsible {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    padding: 10px 25px;
}

.group-title.collapsible:hover {
    background: rgba(255,255,255,0.05);
}

.arrow {
    font-size: 0.8rem;
    transition: var(--transition);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.submenu.open {
    max-height: 500px;
}

.menu-item {
    padding: 14px 25px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.menu-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--accent);
}

/* Custom checkboxes: apariencia consistente en móvil y escritorio */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: inline-block;
    vertical-align: middle;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    position: relative;
}
input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(79,195,247,0.12);
}
input[type="checkbox"]:checked {
    background: linear-gradient(90deg, var(--accent), var(--primary));
    border-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 12px;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* --- OVERLAY MÓVIL --- */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1001;
    backdrop-filter: blur(4px);
}

/* --- CONTENIDO PRINCIPAL --- */
main {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    box-sizing: border-box;
}

.container { max-width: 900px; margin: 0 auto; }

/* --- TARJETAS TIPO DASHBOARD --- */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

h1 { color: white; margin-bottom: 25px; font-weight: 300; }
h2 { color: var(--primary); margin-top: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; font-weight: 400; }

/* --- FORMULARIOS --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.form-group { margin-bottom: 20px; }

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
}

input, select, textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    background: #121212;
    color: white;
    transition: var(--transition);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.15);
}

/* --- BOTÓN NARANJA --- */
/* Contenedor para alinear botones en el formulario */
.form-actions {
    display: flex;
    gap: 15px;      /* Espacio entre los botones */
    margin-top: 20px;
    width: 100%;    /* Ocupa todo el ancho del formulario */
}

.btn-save {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.btn-save:hover {
    background: var(--accent-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 152, 0, 0.4);
}

.btn-cancel {
    background-color: transparent;
    color: #9ca3af; /* Gris apagado */
    border: 1px solid #4b5563; /* Borde sutil */
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px; /* Espacio con el botón de guardar */
}

.btn-cancel:hover {
    color: #f3f4f6; /* Se aclara el texto al pasar el ratón */
    border-color: #9ca3af;
    background-color: rgba(255, 255, 255, 0.05);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    #mobile-header { display: flex; }

    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

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

    main {
        padding: 90px 15px 30px;
    }

    .card { padding: 20px; border-radius: 12px; }
    
    /* Ocultar columnas de detalle en móvil */
    .hide-mobile {
        display: none !important;
    }
    
    /* Grid de 2 columnas para productos y campos específicos en móvil */
    .grid-2-mobile,
    #productos-container .grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px;
    }

    /* Plantaciones */
    .plantaciones-grid {
        grid-template-columns: 1fr;
    }

    /* Quick actions */
    .quick-actions { gap: 8px; }
    .quick-btn { padding: 12px; font-size: 0.95rem; }

    /* Custom checkboxes */
    input[type="checkbox"] { width: 24px; height: 24px; }

    /* Toast en la parte inferior para móviles */
    #toast-container {
        top: auto;
        bottom: 20px;
        width: 95%;
    }
    
    .toast {
        padding: 14px 18px;
        font-size: 0.9rem;
        animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .toast.fade-out {
        animation: fadeOutDown 0.4s ease-out forwards;
    }

    @keyframes slideInUp {
        from {
            opacity: 0;
            transform: translateY(30px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    @keyframes fadeOutDown {
        from {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
        to {
            opacity: 0;
            transform: translateY(20px) scale(0.95);
        }
    }
}

/* --- TABLAS --- */

table {
    width: 100%;
    color: var(--text-main);
    font-size: 0.9rem;
}

th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* Contenedor de acciones para centrar los botones */
.acciones-flex {
    display: flex;
    gap: 8px;
    justify-content: center;
    text-align: center;
}

/* Zebra striping: filas alternas para mejorar legibilidad */
table tbody tr:nth-child(odd) {
    background-color: var(--table-row-odd);
    transition: background-color 0.15s ease;
}
table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}
table tbody tr:hover {
    background-color: var(--table-row-hover) !important;
}

/* Quitar bordes de celdas en todas las tablas */
table, table th, table td {
    border: none;
    padding: 2px 5px;
}

/* Opcional: separar celdas para evitar colapsado de bordes residuales */
table { border-collapse: separate; border-spacing: 0; }

/* Estilo base para botones de icono */
.btn-icon {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ef4444; /* Rojo suave para eliminar */
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    /*display: flex;
    align-items: center;
    justify-content: center;*/
}

/* Efecto al pasar el ratón (Hover) */
.btn-icon:hover {
    background-color: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Efecto al hacer clic */
.btn-icon:active {
    transform: translateY(0);
}

/* Si añades botones de edición en el futuro */
.btn-icon.edit {
    color: #3b82f6; /* Azul */
}
.btn-icon.edit:hover {
    background-color: #3b82f6;
    color: white;
}

/* Toggle switch */
.switch {
    display: inline-block;
    position: relative;
    width: 52px;
    height: 30px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.06);
    transition: background 0.2s ease, border-color 0.2s ease;
    border-radius: 999px;
    border: 1px solid var(--border-color);
}
.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: none;
}
.switch input:checked + .slider {
    /* Fondo azul liso sin sombras ni degradados */
    background: var(--primary);
    border-color: transparent;
}
.switch input:checked + .slider:before {
    transform: translateY(-50%) translateX(22px);
}

/* Small helper to align switch with labels */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Quick access buttons on home */
.quick-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.quick-btn {
    flex: 1 1 140px;
    padding: 14px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.12s ease, opacity 0.12s ease;
}
.quick-btn:hover { transform: translateY(-3px); opacity: 0.98; }
.quick-btn.trabajo { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); }
.quick-btn.recoleccion { background: linear-gradient(90deg, var(--primary), var(--primary-dark)); }
.quick-btn.incidencias { background: #ef4444; }

/* Plantaciones grid */
.plantaciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.plantacion-card {
    background: linear-gradient(135deg, rgba(79, 195, 247, 0.08), rgba(255, 152, 0, 0.08));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    transition: all var(--transition);
    cursor: pointer;
}

.plantacion-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(79, 195, 247, 0.15);
    transform: translateY(-4px);
}

.plantacion-header {
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(79, 195, 247, 0.2);
    padding-bottom: 12px;
}

.plantacion-header h4 {
    color: var(--primary);
    margin: 0 0 6px 0;
    font-weight: 600;
    font-size: 1.1rem;
}

.variedad {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.plantacion-data {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.data-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    text-transform: none;
    font-weight: 500;
}

.data-item .value {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

/* === NOTIFICACIONES TOAST ESTILO ANDROID === */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 500px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    pointer-events: all;
    animation: slideInDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: top center;
}

.toast.success {
    border-left: 4px solid #4caf50;
}

.toast.error {
    border-left: 4px solid #f44336;
}

.toast.info {
    border-left: 4px solid var(--primary);
}

.toast-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

.toast.fade-out {
    animation: fadeOut 0.4s ease-out forwards;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}
}}
