/* ============================================================
   estils.css - Estils globals de l'aplicació AgroGest
   ============================================================ */

/* --- RESET BÀSIC --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7f0;
    color: #333;
}

/* --- CAPÇALERA (topbar) --- */
.topbar {
    background: #2d5016;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar h1 {
    font-size: 24px;
}

.topbar .user {
    font-size: 14px;
}

.topbar a {
    color: #c8e6b0;
    text-decoration: none;
}

.topbar a:hover {
    color: white;
    text-decoration: underline;
}

/* --- CONTENIDOR PRINCIPAL --- */
.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

/* --- MENÚ RÀPID --- */
.menu-rapid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.menu-rapid a {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #2d5016;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
}

.menu-rapid a:hover {
    background: #2d5016;
    color: white;
    transform: translateY(-2px);
}

/* --- BOTÓ HAMBURGUESA (amagat per defecte en PC) --- */
.menu-toggle {
    display: none;
    background: #2d5016;
    color: white;
    border: none;
    font-size: 28px;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

/* --- TARGETES (cards) --- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    text-align: center;
}

.card .numero {
    font-size: 36px;
    font-weight: bold;
    color: #2d5016;
}

.card .label {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

/* --- SECCIONS (taules, formularis) --- */
.section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    overflow-x: auto;
}

.section h2 {
    color: #2d5016;
    border-bottom: 2px solid #e8f0dc;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* --- TAULES --- */
.section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.section table th {
    background: #e8f0dc;
    text-align: left;
    padding: 10px;
}

.section table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.section table tr:hover {
    background: #f8faf4;
}

.empty {
    color: #999;
    text-align: center;
    padding: 20px;
}

/* --- FORMULARIS --- */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4a7c2e;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 124, 46, 0.2);
}

/* --- BOTONS --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-primary {
    background: #2d5016;
    color: white;
}

.btn-primary:hover {
    background: #4a7c2e;
}

.btn-danger {
    background: #c0392b;
    color: white;
}

.btn-danger:hover {
    background: #e74c3c;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #2ecc71;
}

.btn-edit {
    background: #2980b9;
    color: white;
}

.btn-edit:hover {
    background: #3498db;
}

/* --- LOGIN --- */
.login-body {
    background: linear-gradient(135deg, #2d5016, #4a7c2e);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    color: #2d5016;
    text-align: center;
    margin-bottom: 10px;
    font-size: 28px;
}

.login-container .subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-container .error {
    background: #fee;
    color: #c00;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    text-align: center;
    border: 1px solid #fcc;
}

.login-container .footer-login {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #999;
}

.login-container .footer-login strong {
    color: #2d5016;
}

/* ============================================================
   RESPONSIVE PER A MÒBIL (només en pantalles petites)
   ============================================================ */
@media (max-width: 768px) {
    /* Mostrar el botó hamburguesa en mòbil */
    .menu-toggle {
        display: inline-block;
        margin-bottom: 10px;
    }
    
    /* Amagar el menú per defecte en mòbil */
    .menu-rapid {
        display: none;
        flex-direction: column;
        gap: 5px;
        background: #f9fbf7;
        padding: 15px;
        border-radius: 8px;
        border: 1px solid #e0e8d8;
    }
    
    /* Mostrar el menú quan tinga la classe 'mostrar' */
    .menu-rapid.mostrar {
        display: flex;
    }
    
    .menu-rapid a {
        padding: 15px;
        font-size: 18px;
        text-align: center;
        border-radius: 6px;
        width: 100%;
    }
    
    /* Targetes en una columna */
    .cards {
        grid-template-columns: 1fr;
    }
    
    /* Contenidor més estret */
    .container {
        padding: 0 10px;
        margin: 15px auto;
    }
    
    /* Topbar més compacte */
    .topbar {
        padding: 10px 15px;
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
    
    .topbar h1 {
        font-size: 20px;
    }
    
    .topbar .user {
        font-size: 13px;
    }
    
    /* Formularis en columna */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 20px;
        padding: 15px;
    }
    
    /* Botons que ocupen tota l'amplada en mòbil */
    .btn {
        width: 100%;
        text-align: center;
        padding: 15px;
        font-size: 18px;
    }
    
    /* Desplegables dinàmics (produccions, arbres) en columna */
    .form-group > div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Taules desplaçables en mòbil */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 700px;
    }
}

@media (max-width: 480px) {
    .card .numero {
        font-size: 24px;
    }
    
    .section {
        padding: 15px 10px;
    }
    
    .section table {
        font-size: 13px;
    }
    
    .section table th,
    .section table td {
        padding: 8px 6px;
    }
}