/* ============================================================
   LÁNZALO - Estilos globales
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:        #1D9E75;
    --green-dark:   #178A64;
    --green-light:  #E1F5EE;
    --green-mid:    #0F6E56;
    --amber:        #BA7517;
    --amber-light:  #FAEEDA;
    --blue:         #378ADD;
    --blue-light:   #E6F1FB;
    --red:          #E24B4A;
    --red-light:    #FCEBEB;
    --gray:         #888780;
    --gray-light:   #F4F2EB;
    --gray-border:  #E0DDD4;
    --text:         #1A1A18;
    --text-mid:     #444441;
    --text-soft:    #6B6965;
    --text-muted:   #9B9890;
    --white:        #FFFFFF;
    --sidebar-w:    210px;
    --topbar-h:     52px;
    --radius-sm:    6px;
    --radius-md:    8px;
    --radius-lg:    12px;
    --radius-xl:    16px;
    --shadow:       0 2px 12px rgba(0,0,0,0.06);

    /* Tipografía escalable — valores base +1px */
    --fs-2xs:  10px;
    --fs-xs:   12px;
    --fs-sm:   13px;
    --fs-base: 14px;
    --fs-md:   15px;
    --fs-lg:   18px;
    --fs-xl:   20px;
    --fs-2xl:  24px;
}

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-light);
    color: var(--text);
    line-height: 1.5;
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 0.5px solid var(--gray-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 100;
}
.topbar-logo {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
}
.topbar-logo span { color: var(--green); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 0.5px solid var(--gray-border);
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 90;
}
.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-label {
    font-size: var(--fs-2xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 0 1rem 0.4rem;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 1rem;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text-soft);
    text-decoration: none;
    cursor: pointer;
    border-right: 2px solid transparent;
    transition: background 0.1s, color 0.1s;
}
.sidebar-item:hover { background: var(--gray-light); color: var(--text); }
.sidebar-item.active {
    background: var(--green-light);
    color: var(--green-mid);
    font-weight: 500;
    border-right-color: var(--green);
}
.sidebar-icon { width: 16px; text-align: center; font-size: var(--fs-md); }
.sidebar-badge {
    margin-left: auto;
    background: var(--gray-light);
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 10px;
}
.sidebar-badge.alerta { background: var(--red-light); color: var(--red); }

/* ============================================================
   CONTENIDO PRINCIPAL
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
}

/* ============================================================
   CABECERA DE PÁGINA
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 10px;
}
.page-title { font-size: var(--fs-xl); font-weight: 600; color: var(--text); }
.page-subtitle { font-size: var(--fs-base); font-weight: 500; color: var(--text-soft); margin-top: 2px; }

/* ============================================================
   CARDS DE MÉTRICAS
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.metric-card {
    background: var(--white);
    border: 0.5px solid var(--gray-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
}
.metric-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.metric-value { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); line-height: 1.2; }
.metric-sub { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); margin-top: 4px; }
.metric-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 4px;
}

/* ============================================================
   CARDS GENERALES
   ============================================================ */
.card {
    background: var(--white);
    border: 0.5px solid var(--gray-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}
.card-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: 1rem; }

/* ============================================================
   BARRA DE PROGRESO
   ============================================================ */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 0.3s;
}

/* ============================================================
   BADGES / ETIQUETAS
   ============================================================ */
.badge {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 10px;
    white-space: nowrap;
}
.badge-green  { background: var(--green-light);  color: var(--green-mid); }
.badge-amber  { background: var(--amber-light);  color: #633806; }
.badge-blue   { background: var(--blue-light);   color: #0C447C; }
.badge-red    { background: var(--red-light);    color: #A32D2D; }
.badge-gray   { background: var(--gray-light);   color: var(--text-mid); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary {
    background: var(--white);
    color: var(--text-mid);
    border: 0.5px solid var(--gray-border);
}
.btn-secondary:hover { background: var(--gray-light); }
.btn-danger { background: var(--red-light); color: #A32D2D; }
.btn-danger:hover { background: #F5C6C6; }
.btn-sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.form-hint { font-size: var(--fs-xs); font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    color: var(--text);
    background: #FAFAF8;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--green);
    background: var(--white);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}
thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 0.5px solid var(--gray-border);
    background: var(--gray-light);
}
tbody td {
    padding: 11px 12px;
    border-bottom: 0.5px solid var(--gray-border);
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    margin-bottom: 1rem;
}
.alert-success { background: var(--green-light); color: var(--green-mid); border: 1px solid #9FE1CB; }
.alert-error   { background: var(--red-light);   color: #A32D2D;          border: 1px solid #F5C6C6; }
.alert-warning { background: var(--amber-light);  color: #633806;          border: 1px solid #EBC97A; }
.alert-info    { background: var(--blue-light);   color: #0C447C;          border: 1px solid #A8CEEE; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green-mid);
    font-size: var(--fs-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ============================================================
   NOTIFICACIÓN (campana)
   ============================================================ */
.notif-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-soft);
    padding: 4px;
}
.notif-count {
    position: absolute;
    top: 0; right: 0;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CHIPS DE ROL
   ============================================================ */
.role-chip {
    display: inline-block;
    font-size: var(--fs-2xs);
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--gray-light);
    color: var(--text-soft);
    margin: 1px;
}

/* ============================================================
   GRIDS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal-title { font-size: calc(var(--fs-md) + 1px); font-weight: 600; color: var(--text); }
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-soft);
    cursor: pointer;
    padding: 2px 6px;
}
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.text-soft   { color: var(--text-soft);  font-weight: 500; }
.text-muted  { color: var(--text-muted); font-weight: 500; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: var(--fs-sm); }
.text-xs     { font-size: var(--fs-xs); font-weight: 500; }
.fw-500      { font-weight: 500; }
.fw-600      { font-weight: 600; }
.mt-1        { margin-top: 0.5rem; }
.mt-2        { margin-top: 1rem; }
.mt-3        { margin-top: 1.5rem; }
.mb-1        { margin-bottom: 0.5rem; }
.mb-2        { margin-bottom: 1rem; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-1       { gap: 0.5rem; }
.gap-2       { gap: 1rem; }
.flex-1      { flex: 1; }
.hidden      { display: none; }

/* ============================================================
   TOAST NOTIFICATIONS (lanzalo-badges.js)
   ============================================================ */
#lz-toast-box {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.lz-toast {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--text);
    color: #fff;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    animation: lz-toast-in .25s ease;
    max-width: 320px;
}
.lz-toast span { flex: 1; }
.lz-toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.lz-toast-close:hover { color: #fff; }
@keyframes lz-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
