/* ============================================================
 *  1. PALETA CORPORATIVA TIERRA
 * ============================================================ */

:root {
    --verde-tierra: #326354;
    --verde-oscuro: #234137;
    --verde-claro: #f3f8f6;
    --gris-piedra: #4A4A4A;
    --tierra-claro: #fafafa;
    --tierra-oscuro: #535353;
    --gris-suave: #E6E6E6;
    --blanco: #FFFFFF;
    --action-btn-blue: #4A6FA5;
    --action-btn-hover-blue: #3D5C87;
    --action-btn-delete: #C0392B;
    --action-btn-hover-delete: #A93226;
    --olivo: #6B7A3A;
    --olivo-oscuro: #4E5A2A;
    --gris-medio: #3E3E3E;
    --gris-borde: #C8C8C8;
    --gris-fondo: #F5F5F5;
}

/* ============================================================
 *  2. RESET Y REGLAS GLOBALES
 * ============================================================ */

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: var(--tierra-claro);
    color: var(--gris-piedra);
    display: flex;
    flex-direction: column;
}

* {
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

.tierra-main .container {
    margin-top: 20px;
}

/* ============================================================
 *  3. TIPOGRAFÍA Y TÍTULOS
 * ============================================================ */

h1, h2 {
    color: var(--verde-tierra);
    text-align: center;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ============================================================
 *  4. ENLACES
 * ============================================================ */

a {
    color: var(--verde-tierra);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
 *  5. TARJETAS
 * ============================================================ */

.form-card,
.table-card {
    background: var(--blanco);
    padding: 20px;
    border-radius: 10px;
    margin: 20px auto;
    box-shadow: 0 3px 8px rgba(0,0,0,0.10);
    width: 100%;
}

/* ============================================================
 *  6. FORMULARIOS
 * ============================================================ */

form {
    width: auto;
    max-width: none;
    margin: 20px auto;
}

label {
    display: block;
    margin-top: 10px;
    font-weight: 600;
    color: var(--gris-piedra);
}

input,
select {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    border: 1px solid var(--gris-suave);
    border-radius: 6px;
    background: var(--blanco);
    color: var(--gris-piedra);
    font-size: 15px;
}

/* ============================================================
 *  7. BOTONES GLOBALES
 * ============================================================ */

button {
    padding: 12px 15px;
    background-color: var(--verde-tierra);
    color: var(--blanco);
    border: none;
    cursor: pointer;
    border-radius: 6px;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
}

form button:not(.menu-item) {
    margin-top: 15px;
}

button:hover {
    text-decoration: underline;
}

/* ============================================================
 *  8. TABLAS
 * ============================================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--blanco);
    margin-top: 20px;
    border-radius: 10px;
    overflow: hidden;
    font-size: 15px;
}

table th {
    background-color: var(--tierra-oscuro);
    color: var(--blanco);
    padding: 14px;
    font-weight: 600;
    white-space: nowrap;
}

table td {
    padding: 14px;
    border-bottom: 1px solid var(--gris-suave);
    color: var(--gris-piedra);
}

td:last-child,
th:last-child {
    width: 1%;
    white-space: nowrap;
}

/* ============================================================
 *  9. FILTROS Y RESPONSIVE
 * ============================================================ */

.filtros-titulo {
    text-align: center;
    color: var(--verde-oscuro);
    margin-bottom: 10px;
}

.toggle-filtros-btn {
    display: none;
    background: var(--verde-tierra);
    color: var(--blanco);
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    margin: 10px auto;
    cursor: pointer;
}

.filtros-container {
    margin: 20px 0;
}

.filtros-form {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    align-items: flex-end;
    justify-content: center;
}

.filtro-item {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filtro-submit {
    display: flex;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .toggle-filtros-btn { display: block; }
    .filtros-container { display: none; }
    .filtros-container.visible { display: block; }
    .filtros-form {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    .filtro-item { width: 100%; }
}

/* ============================================================
 *  10. MENÚ MODERNO
 * ============================================================ */

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin: 40px auto;
    max-width: 900px;
    width: 100%;
}

.menu-item {
    background: var(--blanco);
    padding: 22px;
    border-radius: 10px;
    text-align: center;
    color: var(--gris-piedra);
    box-shadow: 0 3px 8px rgba(0,0,0,0.10);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--gris-suave);
    cursor: pointer;
    min-height: 120px;
}

.menu-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    border-color: var(--verde-tierra);
}

.menu-item .material-icons {
    font-size: 38px;
    color: var(--tierra-oscuro);
}

.menu-item:hover .material-icons {
    color: var(--verde-oscuro);
}

.menu-form {
    margin: 0;
    padding: 0;
    display: contents;
}

/* ============================================================
 *  11. ACTION BAR
 * ============================================================ */

.action-bar {
    display: flex;
    gap: 12px;
    margin: 20px 0 25px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gris-suave);
}

@media (max-width: 768px) {
    .action-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .action-bar::-webkit-scrollbar { display: none; }
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--verde-tierra);
    color: var(--blanco);
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.15s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.10);
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--verde-oscuro);
    transform: translateY(-2px);
}

.action-btn .material-icons {
    font-size: 20px;
    color: var(--blanco);
}

/* ============================================================
 *  12. PAGINACIÓN
 * ============================================================ */

.pagination-controls {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--gris-borde);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.per-page-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.per-page-form label {
    font-weight: 600;
    color: var(--gris-medio);
}

.per-page-form select {
    padding: 2px 4px;
    border: 1px solid var(--gris-borde);
    border-radius: 4px;
    background-color: var(--gris-fondo);
    color: var(--gris-medio);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-arrow {
    font-size: 20px;
    color: var(--olivo);
    text-decoration: none;
    line-height: 1;
    transition: color 0.2s ease;
}

.page-arrow:hover {
    color: var(--olivo-oscuro);
}

.pagination span {
    color: var(--gris-medio);
    font-weight: 600;
}

/* ============================================================
 *  13. HEADER CORPORATIVO
 * ============================================================ */

.tierra-header {
    background: var(--verde-tierra);
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tierra-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

/* ============================================================
 *  14. UTILIDADES
 * ============================================================ */

.ok-row { background-color: #e6ffe6; }
.error-row { background-color: #ffe6e6; }

.btn-principal {
    background-color: var(--verde-oscuro);
    color: white;
    padding: 10px 18px;
    border: none;
    cursor: pointer;
}

.btn-principal:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.btn-secundario {
    background-color: var(--action-btn-blue);
    padding: 8px 14px;
    border: none;
    cursor: pointer;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================
 *  15. MATERIAL ICONS (UNIFICADO)
 * ============================================================ */

.material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
 *  16. BOTONES DE ACCIÓN PEQUEÑOS (UNIFICADO)
 * ============================================================ */

.action-btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    line-height: 1;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.action-btn-small .material-icons {
    font-size: 16px;
    line-height: 1;
}

.btn-edit {
    background-color: var(--action-btn-blue);
    border-color: #3A567F;
    color: #fff;
}

.btn-edit:hover {
    background-color: var(--action-btn-hover-blue);
}

.btn-delete {
    background-color: var(--action-btn-delete);
    border-color: #922B21;
    color: #fff;
}

.btn-delete:hover {
    background-color: var(--action-btn-hover-delete);
}

/* ============================================================
 *  17. FOOTER CORPORATIVO
 * ============================================================ */

.tierra-footer {
    background: var(--verde-oscuro);
    color: var(--blanco);
    text-align: center;
    padding: 12px 0;
    font-size: 14px;
}

/* ============================================================
 *  18. TABS (Activos / Inactivos)
 * ============================================================ */

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab {
    padding: 8px 16px;
    border-radius: 6px;
    background: #e0e0e0;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover {
    background: #d5d5d5;
}

.tab.active {
    background: #4caf50;
    color: white;
}
