/* ============================================================
   MPGA - Estilos principales
   ============================================================ */

:root {
    --mpga-dark:   #1a3a5c;
    --mpga-mid:    #245080;
    --mpga-accent: #2e6da4;
    --mpga-light:  #e8f0f7;
    --sidebar-w:   240px;
}

/* ---- Layout ---- */
body {
    background: #f4f6f9;
    font-size: 0.9rem;
}

#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--mpga-dark);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

#main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Sidebar ---- */
.sidebar-brand {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

#sidebar .nav-link {
    color: rgba(255,255,255,.72);
    padding: .55rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: 0;
    font-size: .875rem;
    transition: background .15s, color .15s;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    color: #fff;
    background: var(--mpga-mid);
}

#sidebar .nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

.nav-section {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.38);
    padding: .9rem 1.5rem .3rem;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: .75rem 1.5rem;
    color: rgba(255,255,255,.3);
    font-size: .75rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ---- Topbar ---- */
.topbar {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ---- Auth layout ---- */
.auth-body {
    background: linear-gradient(135deg, var(--mpga-dark) 0%, var(--mpga-accent) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    border: none !important;
    border-radius: 14px !important;
    overflow: hidden;
}

.auth-header {
    background: var(--mpga-dark);
    color: #fff;
    padding: 1.25rem 1.5rem;
    text-align: center;
    overflow: hidden;
}

.auth-logo {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: .25rem;
}

.auth-logo-img {
    display: block !important;
    height: 56px !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 auto .5rem !important;
    object-fit: contain !important;
}

.auth-header p {
    opacity: .7;
    margin: 0;
    font-size: .85rem;
    letter-spacing: 1px;
}

/* ---- Stat cards ---- */
.stat-card .card-body {
    padding: 1rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .2rem;
}

.stat-label {
    font-size: .75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ---- Tablas ---- */
.table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
    color: #495057;
}

/* ---- Botón primario con color corporativo ---- */
.btn-primary {
    background-color: var(--mpga-dark);
    border-color: var(--mpga-dark);
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--mpga-mid);
    border-color: var(--mpga-mid);
}

/* ---- Badges ---- */
.badge { font-size: .72rem; }

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    opacity: 0;
    transition: opacity .25s ease;
}
.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ---- Cards responsivas para listas en mobile (generadas por JS) ---- */
/* .tl-table-wrap y .tl-cards controlados por clase body.tl-mobile (agregada por JS) */
.tl-cards { display: none; padding: .5rem; }
body.tl-mobile .tl-table-wrap { display: none !important; }
body.tl-mobile .tl-cards      { display: block !important; }

.tl-card {
    background: #fff;
    border-radius: 10px;
    margin-bottom: .65rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.09);
}

/* Header: título principal + badge de estado */
.tl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .65rem .9rem .5rem;
    border-bottom: 1px solid #f0f0f0;
    gap: .5rem;
    border-radius: 10px 10px 0 0;
}

.tl-title {
    font-weight: 600;
    font-size: .92rem;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.tl-num {
    font-size: .75rem;
    color: #6c757d;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: .3rem;
}

.tl-status { flex-shrink: 0; }

/* Grid: datos en 2 columnas */
.tl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: .35rem .75rem .2rem;
}

.tl-item { padding: .28rem .15rem; }

.tl-lbl {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #9aa0ac;
    margin-bottom: .1rem;
}

.tl-val {
    font-size: .84rem;
    word-break: break-word;
    color: #212529;
}

/* Footer: botones de acción */
.tl-footer {
    padding: .45rem .75rem;
    border-top: 1px solid #f0f0f0;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: .3rem;
    flex-wrap: wrap;
    border-radius: 0 0 10px 10px;
}

/* ---- Cards mobile para items (materiales / tareas) ---- */
.item-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 0;
    margin-bottom: .75rem;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: .45rem .75rem;
}

.item-card-num {
    font-size: .78rem;
    font-weight: 700;
    color: #495057;
}

.item-card > .mb-2,
.item-card > .row {
    padding: .4rem .75rem 0;
}

.item-card > .mb-2:last-child,
.item-card > .row:last-child {
    padding-bottom: .75rem;
}

.item-card-lbl {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #9aa0ac;
    display: block;
    margin-bottom: .2rem;
}

/* ---- table-list: responsive cards en mobile ---- */
@media (max-width: 767.98px) {
    .table-list thead { display: none; }
    .table-list tbody tr {
        display: block;
        border: 1px solid #dee2e6;
        border-radius: 10px;
        margin-bottom: .75rem;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
        overflow: hidden;
    }
    .table-list tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: .45rem .75rem;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        font-size: .875rem;
    }
    .table-list tbody td:last-child { border-bottom: none; }
    .table-list tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .68rem;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: #6c757d;
        flex-shrink: 0;
        margin-right: .75rem;
    }
    .table-list tbody td.td-actions { justify-content: flex-end; }
    .table-list tbody td.td-actions::before { display: none; }
}

/* ---- Targets táctiles mínimos en mobile ---- */
@media (max-width: 767.98px) {
    .btn-group-sm .btn,
    .btn-sm { min-height: 36px; }

    /* Topbar: ocultar título cuando es muy largo */
    .topbar h5 { font-size: .92rem; }

    /* Paginación: no se desborda */
    .pagination { flex-wrap: wrap; gap: 2px; }

    /* Formularios: inputs y selects más cómodos */
    .form-control, .form-select { font-size: .9rem; }
}

/* ---- Responsive general ---- */
@media (max-width: 991.98px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.25); z-index: 1000; }
    #main-content { margin-left: 0; }
}

@media (max-width: 575.98px) {
    .page-content { padding: 1rem .75rem; }
    .topbar { padding: .6rem 1rem; }
    /* Padding seguro para notch iOS */
    .page-content { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }

    /* Cards con padding reducido en mobile */
    .card-body { padding: .75rem; }

    /* Filtros: botones Filtrar/Limpiar full width */
    .card-body .col-auto { flex: 0 0 100%; max-width: 100%; }
    .card-body .col-auto .btn { width: 100%; }

    /* Tablas de detalle (ver.php): texto reducido */
    .table td, .table th { font-size: .82rem; padding: .3rem .4rem; }

    /* Stats de partes (col-4 → col-6 en mobile via CSS) */
    .stats-row .col-4 { flex: 0 0 50%; max-width: 50%; }
}

/* ---- Mobile extra small (< 400px) ---- */
@media (max-width: 399.98px) {
    /* Filtros: 1 columna en pantallas muy pequeñas */
    .card-body .row > [class*="col-6"] { flex: 0 0 100%; max-width: 100%; }
}

