/* ============================================================
   CALMA GO V2 — Estilos principales
   Paleta: Blue #4b6d81 | Teal #00c193 | Yellow #fed743
   ============================================================ */

:root {
    --blue:       #4b6d81;
    --blue-dark:  #3a5566;
    --blue-light: #e8f0f5;
    --teal:       #00c193;
    --teal-dark:  #00a07a;
    --yellow:     #fed743;
    --yellow-dark:#e6c22e;
    --text-dark:  #2d3748;
    --text-mid:   #4a5568;
    --text-light: #718096;
    --bg:         #f0f4f8;
    --white:      #ffffff;
    --border:     #e2e8f0;
    --danger:     #e53e3e;
    --success:    #38a169;
    --warning:    #d69e2e;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
    --radius:     10px;
    --radius-sm:  6px;
    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
img { max-width: 100%; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.3; color: var(--text-dark); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p  { color: var(--text-mid); margin-bottom: 0.75rem; }
small { font-size: 0.82rem; color: var(--text-light); }

/* ============================================================
   AUTH PAGES (Login, Recuperar contraseña)
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 60%, #2a3f4f 100%);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.auth-header {
    background: var(--blue);
    padding: 32px 32px 24px;
    text-align: center;
    border-bottom: 4px solid var(--teal);
}

.auth-header img { height: 52px; }

.auth-header h1 {
    color: var(--white);
    font-size: 1.25rem;
    margin-top: 12px;
}

.auth-body { padding: 32px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-mid);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(0,193,147,0.15);
}

.form-control.is-invalid { border-color: var(--danger); }

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap .form-control { padding-left: 40px; }

.input-icon-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--teal);
    color: var(--white);
}
.btn-primary:hover { background: var(--teal-dark); color: var(--white); }

.btn-secondary {
    background: var(--blue);
    color: var(--white);
}
.btn-secondary:hover { background: var(--blue-dark); color: var(--white); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}
.btn-danger:hover { background: #c53030; color: var(--white); }

.btn-warning {
    background: var(--yellow);
    color: var(--text-dark);
}
.btn-warning:hover { background: var(--yellow-dark); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-mid);
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-danger  { background: #fff5f5; border-left: 4px solid var(--danger);  color: #742a2a; }
.alert-success { background: #f0fff4; border-left: 4px solid var(--success); color: #22543d; }
.alert-warning { background: #fffff0; border-left: 4px solid var(--warning); color: #744210; }
.alert-info    { background: var(--blue-light); border-left: 4px solid var(--blue); color: var(--blue-dark); }

/* ============================================================
   LAYOUT — Sidebar + Main
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--blue);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: width var(--transition);
    overflow-x: hidden;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img { height: 36px; }

.sidebar-logo span {
    font-size: 0.75rem;
    color: var(--teal);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.nav-label {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
}

.nav-item { list-style: none; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--white);
    background: rgba(255,255,255,0.08);
    border-left-color: var(--teal);
}

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

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--teal);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name  { font-size: 0.85rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .role  { font-size: 0.72rem; color: var(--teal); text-transform: capitalize; }

/* MAIN CONTENT */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    background: var(--white);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--text-dark); }

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.page-body { padding: 28px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 22px; }

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 50px; height: 50px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--blue-light); color: var(--blue); }
.stat-icon.teal   { background: rgba(0,193,147,0.12); color: var(--teal); }
.stat-icon.yellow { background: rgba(254,215,67,0.2); color: #b7860a; }
.stat-icon.red    { background: #fff5f5; color: var(--danger); }

.stat-info .value { font-size: 1.6rem; font-weight: 700; color: var(--text-dark); line-height: 1.2; }
.stat-info .label { font-size: 0.8rem; color: var(--text-light); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
    background: var(--bg);
    padding: 12px 16px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    text-align: left;
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: 13px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin    { background: rgba(75,109,129,0.15); color: var(--blue); }
.badge-agente   { background: rgba(0,193,147,0.15);  color: var(--teal-dark); }
.badge-promotor { background: rgba(254,215,67,0.3);  color: #8a6900; }
.badge-activo   { background: rgba(56,161,105,0.15); color: var(--success); }
.badge-inactivo { background: rgba(229,62,62,0.12);  color: var(--danger); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body    { padding: 24px; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-light); }
.text-teal   { color: var(--teal); }
.text-blue   { color: var(--blue); }
.fw-600      { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }
.flex-1 { flex: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 0; }
    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
