/* ============================================
   Bio-Huerto Monroy - Stylesheet Mejorado
   Diseño limpio y profesional
   ============================================ */

/* --- Importar fuentes --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

/* --- Variables CSS --- */
:root {
    /* Colores principales */
    --verde-principal: #4A7C59;
    --verde-hover: #3d6549;
    --verde-claro: #6B9C7C;
    --marron: #5A3E1B;
    --marron-claro: #8B6B3D;
    --crema: #FAF6F0;
    --crema-oscuro: #F0EBE3;
    --dorado: #D4A573;
    --amarillo: #F4D03F;
    --rojo-alerta: #E74C3C;
    --blanco: #FFFFFF;

    /* Grises */
    --gris-texto: #2C3E50;
    --gris-claro: #95A5A6;
    --gris-borde: #E1E8ED;

    /* Tipografía */
    --fuente-principal: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --fuente-titulos: 'Playfair Display', Georgia, serif;

    /* Espaciado */
    --espacio-xs: 0.5rem;
    --espacio-sm: 1rem;
    --espacio-md: 1.5rem;
    --espacio-lg: 2rem;
    --espacio-xl: 3rem;

    /* Bordes */
    --radio-sm: 6px;
    --radio-md: 10px;
    --radio-lg: 14px;

    /* Sombras */
    --sombra-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --sombra-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --sombra-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: var(--fuente-principal);
    background: var(--crema);
    color: var(--gris-texto);
    line-height: 1.6;
    min-height: 100vh;
    /* Altura total de la pantalla */
    font-size: 15px;
    display: flex;
    flex-direction: column;
    /* Alineación vertical */
    margin: 0;
}

h1,
h2,
h3 {
    font-family: var(--fuente-titulos);
    color: var(--marron);
    line-height: 1.2;
    font-weight: 700;
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   PÁGINA DE LOGIN
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--espacio-md);
    background: linear-gradient(135deg, var(--crema) 0%, var(--crema-oscuro) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--blanco);
    padding: var(--espacio-xl);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-lg);
    text-align: center;
}

.logo-container {
    margin-bottom: var(--espacio-md);
}

.logo-plant {
    font-size: 3.5rem;
    display: inline-block;
}

.login-card h1 {
    margin-bottom: var(--espacio-xs);
    font-size: 1.875rem;
}

.subtitle {
    color: var(--marron-claro);
    font-size: 0.9375rem;
    margin-bottom: var(--espacio-lg);
    font-weight: 400;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: var(--espacio-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--espacio-xs);
    color: var(--gris-texto);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem var(--espacio-sm);
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio-sm);
    font-family: var(--fuente-principal);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--blanco);
}

.form-group input:focus {
    outline: none;
    border-color: var(--verde-principal);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}

.error {
    color: var(--rojo-alerta);
    font-size: 0.825rem;
    margin-top: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.error::before {
    content: '⚠';
    padding-right: 0.25rem;
    font-size: 1rem;
}


.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background: var(--verde-principal);
    color: var(--blanco);
    border-radius: var(--radio-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    margin-top: var(--espacio-sm);
    box-shadow: var(--sombra-sm);
}

.btn-primary:hover {
    background: var(--verde-hover);
    box-shadow: var(--sombra-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.login-footer {
    margin-top: var(--espacio-lg);
    color: var(--gris-claro);
    font-size: 0.8125rem;
}

/* ============================================
   HEADER PRINCIPAL
   ============================================ */

.main-header {
    background: var(--blanco);
    box-shadow: var(--sombra-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--verde-principal);
    width: 100%;
    flex-shrink: 0;
    /* Impide que se encojan */
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--espacio-md) var(--espacio-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--espacio-md);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--espacio-sm);
}

.brand .logo-plant {
    font-size: 2rem;
}

.brand h1 {
    font-size: 1.5rem;
    margin: 0;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: var(--espacio-md);
}

.greeting {
    color: var(--gris-texto);
    font-size: 0.9375rem;
}

.greeting strong {
    color: var(--marron);
    font-weight: 600;
}

.btn-logout {
    padding: 0.625rem 1.25rem;
    background: var(--dorado);
    color: var(--blanco);
    border-radius: var(--radio-sm);
    font-size: 0.875rem;
    font-weight: 600;
}

.btn-logout:hover {
    background: var(--marron);
    transform: translateY(-1px);
    box-shadow: var(--sombra-sm);
}

/* ============================================
   BARRA DE ESTADÍSTICAS
   ============================================ */

.stats-bar {
    background: var(--verde-principal);
    padding: var(--espacio-sm) var(--espacio-lg);
    box-shadow: var(--sombra-sm);
    width: 100%;
    flex-shrink: 0;
    /* Impide que se encojan */
}

.stats-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--espacio-lg);
    flex-wrap: wrap;
}

.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 0.625rem 1rem;
    border-radius: var(--radio-sm);
    display: flex;
    align-items: center;
    gap: var(--espacio-sm);
    color: var(--blanco);
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-info {
    text-align: left;
}

.stat-label {
    font-size: 0.8125rem;
    opacity: 0.9;
    margin-bottom: 0.125rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.btn-simulate {
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: var(--blanco);
    border-radius: var(--radio-sm);
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--espacio-xs);
    box-shadow: var(--sombra-sm);
}

.btn-simulate:hover {
    background: linear-gradient(135deg, #EE5A52 0%, #FF7043 100%);
    transform: translateY(-1px);
    box-shadow: var(--sombra-md);
}

.btn-icon {
    font-size: 1.25rem;
}

/* ============================================
   MENSAJES FLASH
   ============================================ */

.flash-messages {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--espacio-md) var(--espacio-lg) 0;
    width: 100%;
    flex-shrink: 0;
}

.flash {
    /*background: #D5F4E6;*/
    border-left: 4px solid #27AE60;
    padding: var(--espacio-sm) var(--espacio-md);
    border-radius: var(--radio-sm);
    display: flex;
    align-items: center;
    gap: var(--espacio-sm);
    margin-bottom: var(--espacio-md);
}

.flash-success {
    background: #D5F4E6;
    border-left-color: #27AE60;
    color: #1E8449;
}

.flash-error {
    background: #FDECEA;
    border-left-color: var(--rojo-alerta);
    color: var(--rojo-alerta);
}

.msg-success {
    color: var(--verde-principal);
    border-left: 3px solid var(--verde-hover);
    background: var(--verde-claro);

}

.msg-error {
    background: #FDECEA;
    color: var(--rojo-alerta);
    border-left: 3px solid var(--rojo-alerta);
}


.flash-icon {
    font-size: 1.25rem;
    font-weight: 700;
}

.flash-text {
    flex: 1;
    font-size: 0.9375rem;
}

.flash-close {
    background: none;
    color: inherit;
    font-size: 1.5rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.flash-close:hover {
    opacity: 1;
}

/* ============================================
   DASHBOARD PRINCIPAL
   ============================================ */

.dashboard-main {
    flex: 1 0 auto;
    /* Crece para ocupar el espacio sobrante */
    width: 100%;
    /* Asegura el ancho total */
    max-width: 1400px;
    margin: 0 auto;
    padding:20px 20px;
    box-sizing: border-box;
}

.plantas-section h2 {
    margin-bottom: var(--espacio-lg);
    font-size: 1.875rem;
}

.plantas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--espacio-lg);
}

/* ============================================
   TARJETAS DE PLANTAS
   ============================================ */

.card-planta {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    overflow: hidden;
    box-shadow: var(--sombra-md);
    transition: all 0.3s ease;
}

.card-planta:hover {
    transform: translateY(-4px);
    box-shadow: var(--sombra-lg);
}

.card-planta.peligro {
    border: 2px solid var(--rojo-alerta);
}

.planta-imagen {
    height: 200px;
    overflow: hidden;
    background: var(--crema-oscuro);
}

.planta-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.planta-info {
    padding: var(--espacio-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--espacio-sm);
}

.planta-nombre {
    font-size: 1.25rem;
    margin: 0;
    color: var(--marron);
}

.planta-tipo {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tipo-hortaliza {
    background: #E8F5E9;
    color: #2E7D32;
}

.tipo-aromatica {
    background: #FFF3E0;
    color: #E65100;
}

.tipo-fruta {
    background: #FCE4EC;
    color: #C2185B;
}

.humedad-container {
    padding: 0 var(--espacio-md) var(--espacio-md);
}

.humedad-label {
    font-size: 0.875rem;
    margin-bottom: var(--espacio-xs);
    color: var(--gris-texto);
}

.humedad-label strong {
    color: var(--verde-principal);
    font-weight: 600;
}

.peligro .humedad-label strong {
    color: var(--rojo-alerta);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--crema-oscuro);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--verde-claro);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.peligro .progress-fill {
    background: var(--rojo-alerta);
}

.planta-acciones {
    padding: var(--espacio-md);
    padding-top: 0;
    display: flex;
    gap: var(--espacio-sm);
    align-items: center;
}

.planta-acciones form {
    flex: 1;
}

.planta-acciones form:last-child {
    flex: 0;
}

.btn-regar {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--verde-principal);
    color: var(--blanco);
    border-radius: var(--radio-sm);
    font-weight: 600;
    font-size: 0.9375rem;
    box-shadow: var(--sombra-sm);
}

.btn-regar:hover {
    background: var(--verde-hover);
    transform: translateY(-1px);
    box-shadow: var(--sombra-md);
}

.link-detalle {
    color: var(--verde-principal);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: var(--radio-sm);
    transition: all 0.2s ease;
    background: transparent;
    white-space: nowrap;
}

.link-detalle:hover {
    background: var(--crema-oscuro);
    color: var(--verde-hover);
}

.datos-tecnicos {
    background: var(--crema-oscuro);
    /* Un poco más oscuro para que resalte */
    margin: 0 var(--espacio-md) var(--espacio-sm);
    padding: 0.6rem var(--espacio-sm) !important;
    border-radius: var(--radio-sm);
    display: flex;
    justify-content: space-between;
    border: 1px dashed var(--gris-claro);
    /* Toque profesional */
}

.datos-tecnicos span {
    display: flex;
    flex-direction: column;
    /* Cambiado a column para que el label esté sobre el valor */
    align-items: center;
    font-size: 0.7rem;
    color: var(--marron-claro);
    font-weight: 600;
}

.datos-tecnicos strong {
    color: var(--marron);
    font-weight: 700;
    font-size: 0.9rem;
}

/* ============================================
   PÁGINA DE DETALLE/HISTORIAL
   ============================================ */

.detalle-main {
    flex: 1 0 auto;
    /* Crece para ocupar el espacio sobrante */
    width: 100%;
    /* Asegura el ancho total */
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.detalle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--espacio-xl);
    flex-wrap: wrap;
    gap: var(--espacio-md);
}

.detalle-title {
    display: flex;
    align-items: center;
    gap: var(--espacio-sm);
}

.detalle-title h2 {
    margin: 0;
    font-size: 2rem;
}

.btn-volver {
    padding: 0.75rem 1.5rem;
    background: var(--marron);
    color: var(--blanco);
    border-radius: var(--radio-sm);
    font-weight: 600;
    box-shadow: var(--sombra-sm);
    font-size: 0.9375rem;
}

.btn-volver:hover {
    background: var(--marron-claro);
    transform: translateY(-1px);
    box-shadow: var(--sombra-md);
}

.historial-section {
    background: var(--blanco);
    padding: var(--espacio-xl);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-md);
    margin-bottom: var(--espacio-xl);
}

.historial-section h3 {
    margin-bottom: var(--espacio-lg);
    font-size: 1.5rem;
}

.table-container {
    overflow-x: auto;
    border-radius: var(--radio-md);
    border: 1px solid var(--gris-borde);
}

.historial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.historial-table thead {
    background: var(--verde-principal);
    color: var(--blanco);
}

.historial-table th {
    padding: var(--espacio-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.historial-table td {
    padding: var(--espacio-md);
    border-bottom: 1px solid var(--gris-borde);
}

.historial-table tbody tr {
    transition: background 0.2s ease;
}

.historial-table tbody tr:nth-child(even) {
    background: var(--crema);
}

.historial-table tbody tr:hover {
    background: var(--crema-oscuro);
}

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

/* .estadisticas-planta {
    background: var(--blanco);
    padding: var(--espacio-xl);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-md);
}

.estadisticas-planta h3 {
    margin-bottom: var(--espacio-lg);
    font-size: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--espacio-md);
}

.stat-item {
    background: var(--crema);
    padding: var(--espacio-lg);
    border-radius: var(--radio-md);
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.stat-item:hover {
    border-color: var(--verde-claro);
    transform: translateY(-2px);
    box-shadow: var(--sombra-sm);
}

.stat-item .stat-icon {
    font-size: 2.5rem;
    margin-bottom: var(--espacio-sm);
}

.stat-item .stat-label {
    font-size: 0.875rem;
    color: var(--marron-claro);
    margin-bottom: var(--espacio-xs);
}

.stat-item .stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--verde-principal);
    font-family: var(--fuente-titulos);
} */

/* ============================================
   FOOTER PRINCIPAL
   ============================================ */

.main-footer {
    background: var(--verde-principal);
    color: var(--blanco);
    padding: var(--espacio-lg);
    text-align: center;
    /* margin-top: var(--espacio-xl); */
    margin-top: auto;
    width: 100%;
    flex-shrink: 0;     /* Evita que flexbox lo intente comprimir */
    margin-top: auto;   /* Lo mantiene pegado abajo */
}

.main-footer p {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.95;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (min-width: 1200px) {
    .plantas-grid {
        /* Esto garantiza 3 columnas exactas en pantallas grandes */
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .header-content {
        padding: var(--espacio-sm) var(--espacio-md);
        flex-direction: column;
        align-items: flex-start;
    }

    .brand h1 {
        font-size: 1.25rem;
    }

    .user-nav {
        width: 100%;
        justify-content: space-between;
    }

    .stats-content {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-card {
        justify-content: center;
    }

    .btn-simulate {
        justify-content: center;
    }

    .flash-messages {
        padding: var(--espacio-sm) var(--espacio-md) 0;
    }

    .plantas-grid {
        display: grid;
        /* Subimos de 320px a 400px para forzar 3 columnas en escritorio */
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
        gap: var(--espacio-lg);
    }

    .detalle-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .detalle-title h2 {
        font-size: 1.5rem;
    }

    .historial-section,
    .estadisticas-planta {
        padding: var(--espacio-md);
    }

    .historial-table {
        font-size: 0.875rem;
    }

    .historial-table th,
    .historial-table td {
        padding: var(--espacio-sm);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: var(--espacio-lg);
    }

    .logo-plant {
        font-size: 3rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .planta-acciones {
        flex-direction: column;
    }

    .planta-acciones form:last-child {
        flex: 1;
        width: 100%;
    }

    .link-detalle {
        width: 100%;
        text-align: center;
    }


}