/* ============================================
   Corredora de Seguros — Estilos principales
   ============================================ */

/* --- Variables Globales --- */
:root {
    --topbar-height: 52px;
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius: 4px;
    --radius-sm: 2px;
    --shadow: none;
    --shadow-lg: none;
    --transition: all 0.15s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg, #f0f2f5);
    color: var(--text, #111827);
    line-height: 1.4;
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: var(--primary, #1e40af);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-light, #1e3a8a);
}

/* ── Layout Desktop (Horizontal Nav) ── */

/* Header / Navbar */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height, 52px);
    background: var(--bg-card, #fff);
    border-bottom: 1px solid var(--border, #d1d5db);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    z-index: 1050;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text, #111827);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.15s;
}
.header-btn:hover {
    background: var(--bg, #f0f2f5);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary, #1e40af);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
}
.header-brand:hover {
    color: var(--primary-light, #1e3a8a);
}
.header-brand i {
    font-size: 1.25rem;
}
.header-logo {
    /* El logo se reescala server-side a 50x50 (SaaSController::escalarLogo()),
       pero esta regla queda como resguardo — sin ella un logo SVG (que no
       pasa por el reescalado, es vectorial) o un archivo ya subido antes
       del fix podía romper el layout del header al no tener ningún límite
       de tamaño. */
    max-height: 32px;
    max-width: 120px;
    width: auto;
    object-fit: contain;
}

/* Navigation menu (horizontal) */
.header-nav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: visible;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    flex-shrink: 0;
}

.nav-menu-item {
    position: relative;
    margin: 0;
    flex-shrink: 0;
}

/* <a> and <button> variants for nav-menu-link */
.nav-menu-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    color: var(--text, #111827);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    border-bottom: 2px solid transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    line-height: inherit;
    width: auto;
}
.nav-menu-link:hover {
    background: var(--bg, #f0f2f5);
    color: var(--primary, #1e40af);
}
.nav-menu-link.active {
    color: var(--primary, #1e40af);
    border-bottom-color: var(--primary, #1e40af);
}
.nav-menu-link i {
    width: 16px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
/* Dropdown caret for <button> toggle */
.nav-menu-link.dropdown-toggle::after {
    display: inline-block;
    font-size: 0.65rem;
    margin-left: 0.3rem;
    vertical-align: middle;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
}

/* Dropdown del menú horizontal */
.nav-dropdown-menu {
    border: 1px solid var(--border, #d1d5db);
    border-radius: 0;
    box-shadow: none;
    padding: 0.25rem 0;
    margin-top: 0;
}
.nav-dropdown-menu .dropdown-item {
    padding: 0.4rem 1rem;
    font-size: 0.83rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-dropdown-menu .dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light, #6b7280);
}
.nav-dropdown-menu .dropdown-item:hover {
    background: var(--bg, #f0f2f5);
}

/* Header right */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    width: auto;
    font-size: 0.85rem;
    color: var(--text, #111827);
}
.profile-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-notify {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
    padding: 0.15em 0.35em;
    border-radius: 0;
    line-height: 1;
    min-width: 16px;
    text-align: center;
}

/* Mensajes dropdown */
.messages-menu {
    width: 360px;
    max-height: 400px;
    overflow-y: auto;
    border-radius: 0;
    border: 1px solid var(--border, #d1d5db);
    box-shadow: none;
}
.message-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border, #d1d5db);
}
.message-item:last-child {
    border-bottom: none;
}
.message-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.message-error .message-icon { color: var(--danger, #b91c1c); }
.message-warning .message-icon { color: var(--warning, #b45309); }
.message-deprecate .message-icon { color: var(--info, #2563eb); }
.message-info .message-icon { color: var(--primary, #1e40af); }
.message-content strong {
    display: block;
    font-size: 0.83rem;
    margin-bottom: 0.15rem;
}
.message-content p {
    font-size: 0.78rem;
    margin: 0;
    color: var(--text-light, #6b7280);
}
.message-close {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text-light, #6b7280);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.15rem 0.3rem;
    border-radius: 2px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    opacity: 0.5;
}
.message-close:hover {
    color: var(--danger, #b91c1c);
    background: rgba(185, 28, 28, 0.1);
    opacity: 1;
}
.message-item.removing {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Skin dropdown */
.skin-dropdown-menu {
    border-radius: 0;
    border: 1px solid var(--border, #d1d5db);
    box-shadow: none;
    min-width: 200px;
}

/* ── Mobile Sidebar ── */
.mobile-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    background: var(--primary, #1e40af);
    color: #fff;
    z-index: 1060;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.mobile-sidebar.open {
    transform: translateX(0);
}

.mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: var(--topbar-height, 52px);
}

.mobile-sidebar .sidebar-brand {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}
.mobile-sidebar .sidebar-brand i {
    font-size: 1.2rem;
}
.sidebar-logo {
    /* Resguardo — ver comentario de .header-logo arriba. */
    max-height: 36px;
    max-width: 140px;
    width: auto;
    object-fit: contain;
}
.mobile-sidebar .header-btn {
    color: rgba(255,255,255,0.75);
}
.mobile-sidebar .header-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.mobile-sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.mobile-sidebar .nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-sidebar .nav-item {
    margin: 0;
}

.mobile-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.mobile-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent, #1e3a8a);
}
.mobile-sidebar .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
}

/* Sidebar grupos */
.sidebar-grupo {
    margin-bottom: 0.15rem;
}
.sidebar-grupo-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
    user-select: none;
}
.sidebar-grupo-header i {
    width: 16px;
    text-align: center;
    font-size: 0.7rem;
}
.sidebar-grupo .nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-sidebar-footer {
    padding: 0.6rem 0.85rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1055;
}
.sidebar-backdrop.show {
    display: block;
}

/* ── Main Content ── */
.app-main {
    margin-top: var(--topbar-height, 52px);
    min-height: calc(100vh - var(--topbar-height, 52px));
    background: var(--bg, #f0f2f5);
}

.page-container {
    padding: 1rem 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Page Title (dentro del contenido) ── */
.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text, #111827);
    margin: 0;
}

/* --- Cards --- */
.card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e1e8ed);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card-header {
    background: var(--bg-card, #fff);
    border-bottom: 1px solid var(--border, #e1e8ed);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}
.card-body {
    padding: 1.25rem;
}
.card-footer {
    background: var(--bg-card, #fff);
    border-top: 1px solid var(--border, #e1e8ed);
    padding: 0.75rem 1.25rem;
}

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th {
    background: var(--bg, #f4f7fa);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border, #e1e8ed);
    white-space: nowrap;
}
.table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border, #e1e8ed);
    vertical-align: middle;
}
.table tr:hover {
    background: rgba(0,0,0,0.02);
}
.table-actions {
    white-space: nowrap;
    text-align: right;
}
.table-actions .btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--text, #2c3e50);
}
.form-control {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border, #e1e8ed);
    border-radius: var(--radius-sm);
    background: var(--bg-card, #fff);
    color: var(--text, #2c3e50);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-light, #2e86de);
    box-shadow: 0 0 0 3px rgba(46, 134, 222, 0.15);
}
.form-control.is-invalid {
    border-color: var(--danger, #e74c3c);
}
.field-error {
    color: var(--danger, #e74c3c);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: block;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary {
    background: var(--primary, #1b3a5c);
    color: #fff;
    border-color: var(--primary, #1b3a5c);
}
.btn-primary:hover {
    background: var(--primary-light, #2e86de);
    border-color: var(--primary-light, #2e86de);
}
.btn-success {
    background: var(--success, #27ae60);
    color: #fff;
}
.btn-danger {
    background: var(--danger, #e74c3c);
    color: #fff;
}
.btn-warning {
    background: var(--warning, #f39c12);
    color: #fff;
}
.btn-info {
    background: var(--info, #3498db);
    color: #fff;
}
.btn-outline-primary {
    background: transparent;
    color: var(--primary, #1b3a5c);
    border-color: var(--primary, #1b3a5c);
}
.btn-outline-primary:hover {
    background: var(--primary, #1b3a5c);
    color: #fff;
}
.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}
.btn-lg {
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
}
.bg-success { background: var(--success, #27ae60); color: #fff; }
.bg-danger { background: var(--danger, #e74c3c); color: #fff; }
.bg-warning { background: var(--warning, #f39c12); color: #1a1a1a; }
.bg-info { background: var(--info, #3498db); color: #fff; }
.bg-secondary { background: #95a5a6; color: #fff; }

/* --- Avatar --- */
.avatar {
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

/* --- Skin Selector --- */
.skin-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.skin-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border, #e1e8ed);
}

/* --- Login Page --- */
.public-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary, #1b3a5c) 0%, var(--primary-light, #2e86de) 100%);
    padding: 1rem;
}

/* --- Stats / Dashboard --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e1e8ed);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(52, 152, 219, 0.15); color: #3498db; }
.stat-icon.green  { background: rgba(39, 174, 96, 0.15); color: #27ae60; }
.stat-icon.orange { background: rgba(243, 156, 18, 0.15); color: #f39c12; }
.stat-icon.red    { background: rgba(231, 76, 60, 0.15); color: #e74c3c; }
.stat-icon.purple { background: rgba(155, 89, 182, 0.15); color: #9b59b6; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text, #2c3e50);
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-light, #7f8c8d);
    margin-top: 0.15rem;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

/* --- Filters --- */
.filters-bar {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e1e8ed);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filters-bar .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light, #7f8c8d);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text, #2c3e50);
}

/* --- Utilities --- */
.text-muted { color: var(--text-light, #7f8c8d); }
.text-primary { color: var(--primary, #1b3a5c); }
.text-danger { color: var(--danger, #e74c3c); }
.text-success { color: var(--success, #27ae60); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.ms-auto { margin-left: auto; }
.me-auto { margin-right: auto; }
/* white-space por sí solo respeta saltos de línea pero NO corta una
   cadena continua sin espacios (ej. texto pegado por error, o un
   intento de romper el layout) — overflow-wrap la fuerza a partirse
   igual, sin desbordar el contenedor. */
.text-pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

/* ── Responsive ── */

/* Tablet / Mobile: activar sidebar lateral */
@media (max-width: 991px) {
    .header-nav {
        display: none; /* oculta menú horizontal */
    }
    .mobile-sidebar {
        display: flex; /* muestra sidebar lateral */
    }
    .header-profile .profile-name {
        display: none;
    }
    .page-container {
        padding: 0.85rem 0.85rem;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .filters-bar {
        flex-direction: column;
    }
    .filters-bar .form-group {
        min-width: 100%;
    }
    .page-container {
        padding: 0.75rem 0.65rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .d-none-sm {
        display: none !important;
    }
}
