/* =========================
   BASE GLOBAL RESPONSIVA
   ========================= */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    background: #f6f7fb;
    color: #111827;
    overflow-x: hidden; /* evita scroll horizontal */
}

/* Título principal de cada formulario */
h2 {
    text-align: left;
    font-size: 22px;
    margin: 16px auto 8px;
    width: min(1400px, 95vw);
    color: #111827;
    font-weight: 600;
    letter-spacing: .2px;
}

/* =========================
   CONTENEDORES PRINCIPALES
   ========================= */

/* Barra de botones (Nuevo, etc.) */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 8px;
    margin: 0 auto;
    width: min(1400px, 95vw);
    justify-content: flex-start;
}

.action-buttons button {
    background: #ffffff;
    color: #111827;
    border: 1px solid #d0d5dd;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s ease, box-shadow .15s ease, transform .02s ease;
}

.action-buttons button:hover {
    background: #f9fafb;
}

/* Caja donde van tablas y formularios */
.form-container {
    margin: 8px auto 0;
    width: min(1400px, 95vw);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

/* Contenedor de tabs (pestañas) */
.tab-container {
    margin: 20px auto 0;
    width: min(1400px, 95vw);
}

/* =========================
   FORMULARIOS
   ========================= */

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    margin: 6px 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
}

/* Fila de formulario (para agrupar campos en columnas) */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.form-row > div {
    flex: 1 1 220px;   /* se adapta, pero no se hace mínimo mínimo */
    min-width: 180px;
}

/* =========================
   TABLAS
   ========================= */

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;        /* si la tabla es muy ancha, scroll horizontal */
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
}

/* Para tablas “principales” con scroll vertical interior */
.table-container.table-main {
    max-height: 62vh;
    overflow-y: auto;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f2f4f7;
    color: #111827;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
}

tbody td {
    border-bottom: 1px solid #e5e7eb;
    padding: 9px 12px;
    font-size: 13px;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: transparent;
}

/* Filas alternadas y hover */
tbody tr:nth-child(odd) { background: #ffffff; }
tbody tr:nth-child(even){ background: #fafbfc; }
tbody tr:hover { background: #eef2f7; }

/* Fila seleccionada */
.selected-row {
    outline: 2px solid #6d28d9;
    outline-offset: -2px;
}

/* =========================
   TABS
   ========================= */

.tab {
    display: flex;
    gap: 8px;
    margin: 0 0 8px;
    flex-wrap: wrap;
}

.tab button {
    background: #ffffff;
    border: 1px solid #d0d5dd;
    color: #111827;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease;
    font-size: 14px;
}

.tab button:hover {
    background: #f9fafb;
}

.tab button.active {
    background: #eef2f7;
    border-color: #cfd5df;
}

.tabcontent {
    display: none;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

/* =========================
   MODALES
   ========================= */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,.35);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 10px;  /* margen interior para pantallas pequeñas */
}

.modal-content {
    background: #ffffff;
    color: #111827;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid #e5e7eb;
    width: min(900px, 95vw);    /* RESPONSIVO */
    max-height: 90vh;           /* no más alto que la pantalla */
    overflow-y: auto;           /* scroll interno si hace falta */
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(16,24,40,.2);
}

.close {
    float: right;
    font-size: 26px;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
}

.close:hover {
    color: #111827;
}

/* =========================
   BOTONES GENÉRICOS
   ========================= */

.btn-primary {
    background: #3b82f6;
    color: #ffffff;
    border: 1px solid #60a5fa;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

/* Reutilizables tipo Editar / Eliminar */
.btn-edit,
.btn-delete,
.btn-poliza {
    background: #ffffff;
    color: #111827;
    border: 1px solid #d0d5dd;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.btn-edit {
    background: #fde68a;
    color: #1f2937;
    border-color: #fbbf24;
}

.btn-delete {
    background: #fca5a5;
    color: #7f1d1d;
    border-color: #fca5a5;
}

.btn-poliza {
    background: rgba(109,40,217,.08);
    color: #312e81;
    border-color: rgba(109,40,217,.35);
}

/* contenedor interno de botones en tablas */
.row-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}

/* =========================
   BÚSQUEDA
   ========================= */

#searchInput {
    width: 420px;
    max-width: 100%;
    padding: 10px 12px;
    background: #ffffff;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    margin-bottom: 12px;
}

/* =========================
   MEDIA QUERIES
   ========================= */

/* Tablets / pantallas medianas */
@media (max-width: 1024px) {
    h2 {
        font-size: 18px;
    }

    .form-container {
        padding: 10px;
    }

    thead th, tbody td {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* Móviles / pantallas chicas */
@media (max-width: 768px) {

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .tab {
        flex-direction: row;
    }

    .tab button {
        flex: 1 1 100%;
        text-align: center;
    }

    .form-row {
        flex-direction: column;  /* formulario en una sola columna */
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
    }

    #searchInput {
        width: 100%;
    }
}
