/* ── BLOQUEO DE SCROLL GLOBAL Y MAXIMIZACIÓN DE ESPACIO ── */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100dvh !important; /* 100dvh soluciona el bug de scroll en iOS/Android */
    overflow: hidden !important; /* Bloquea todo el scroll del navegador */
}

.app-layout {
    height: 100dvh;
    width: 100vw;
    display: flex;
    overflow: hidden;
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── PROTECCIÓN DEL HEADER (TOP-BAR) ── */
.top-bar {
    flex-wrap: nowrap !important;
    display: flex;
    align-items: center;
}

.top-bar h1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Contenedor de botones inyectado en el header */
.header-buttons-container {
    margin-left: auto;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: center;
}

/* ── ESTRUCTURA MAIN Y CONTENEDOR FLEX ── */
main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
    padding: 20px !important;
    overflow: hidden !important;
    box-sizing: border-box;
    min-height: 0;
}

.content-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100% !important;
    max-height: 100% !important;
    text-align: left !important;
    padding: 20px !important;
    border-radius: 16px !important;
    overflow: hidden !important; /* Todo el scroll será estrictamente interno */
    box-sizing: border-box;
    min-height: 0;
}

.content-box > i.main-icon {
    display: none !important;
}

/* ── BOTONES GLOBALES ────────────────────────────── */
.btn { 
    padding: 9px 16px; 
    border-radius: 8px; 
    font-weight: 600; 
    font-size: 0.9rem; 
    cursor: pointer; 
    border: none; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 7px; 
    transition: all 0.2s; 
    height: 38px; 
    white-space: nowrap; 
    flex-shrink: 0; 
    font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--text-dark, #0F172A); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.05); opacity: 0.9; }
.btn-outline { background: white; color: var(--text-dark, #0F172A); border: 1px solid var(--border-color, #CBD5E1); }
.btn-outline:hover { background: var(--sidebar-hover, #f1f5f9); }
.btn-danger { background: var(--cr-red, #EE3224); color: white; }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.05); opacity: 0.9; }

.icon-btn { background: var(--sidebar-hover, #f1f5f9); border: 1px solid transparent; cursor: pointer; color: var(--text-dark, #0F172A); width: 34px; height: 34px; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 1rem; transition: all 0.2s; flex-shrink: 0; }
.icon-btn:hover { background: #e2e8f0; border-color: var(--border-color, #CBD5E1); }
.icon-btn.btn-delete:hover { color: var(--cr-red, #EE3224); background: #ffe4e6; border-color: #fda4af; }

/* ── MODALS GLOBALES ──────────────────────────────────────── */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15,23,42,0.6); z-index: 10000; justify-content: center; align-items: center; backdrop-filter: blur(4px); padding: 20px; box-sizing: border-box; }
.modal.active { display: flex; animation: fadeIn 0.2s; }
.modal-content { background: white; padding: 32px; border-radius: 20px; text-align: center; max-width: 480px; width: 100%; position: relative; box-shadow: 0 15px 35px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto; box-sizing: border-box; }
.close-modal { position: absolute; top: 20px; right: 24px; cursor: pointer; font-size: 1.5rem; color: var(--text-muted, #64748B); transition: color 0.2s; }
.close-modal:hover { color: var(--cr-red, #EE3224); }

/* ── FORM HELPERS ────────────────────────────────── */
.form-label { display:block; margin-bottom:6px; font-weight:700; color: var(--text-dark, #0F172A); font-size:0.9rem; }
.form-input { width:100%; padding:12px; border:1px solid var(--border-color, #CBD5E1); border-radius:8px; box-sizing:border-box; font-size:0.95rem; outline:none; transition: border-color 0.2s, box-shadow 0.2s; background: #fff; font-family: 'Inter', sans-serif;}
.form-input:focus { border-color: var(--text-dark, #0F172A); box-shadow: 0 0 0 3px rgba(15,23,42,0.1); }
.form-row { display:flex; gap:16px; margin-bottom:16px; }
.form-row > div { flex:1; min-width:0; }
.form-group { margin-bottom:16px; }

/* ── RESPONSIVE PLANTILLA GENÉRICA ──────────────────────────────────── */
@media (max-width: 768px) {
    main { padding: 12px !important; }
    .content-box { padding: 16px !important; }
    .hide-on-mobile { display: none !important; }
    
    .header-buttons-container { gap: 6px; }
    .header-buttons-container .btn { padding: 8px 12px; font-size: 1rem;} /* Icono un poco más grande en móvil */
    .modal-content { padding: 24px 20px; }
    .form-row { flex-direction: column; gap: 12px; }
}