/* ═══════════════════════════════════════════════════════════
   BRÚJULA INTELIGENTE — Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
    --primary:   #3b82f6;
    --primary-h: #2563eb;
    --bg:        #0f1923;
    --surface:   #1e2a3a;
    --surface2:  #162030;
    --surface3:  #253447;
    --border:    #2a3f58;
    --text:      #e2eaf3;
    --muted:     #7a9ab8;
    --success:   #22c55e;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --info:      #06b6d4;
    --radius:    10px;
    --navbar:    56px;
    --sidebar:   240px;
}

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

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    min-height: 100vh;
}

/* ── Bootstrap overrides ── */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-h);
    border-color: var(--primary-h);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #fff;
}

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.card-header {
    background-color: var(--surface2);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.table {
    color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,0.03);
    --bs-table-hover-bg: rgba(59,130,246,0.08);
    --bs-table-border-color: var(--border);
}
.table thead th {
    background-color: var(--surface2);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

.form-control, .form-select {
    background-color: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--surface2);
    border-color: var(--primary);
    color: var(--text);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.form-control::placeholder { color: var(--muted); }
.form-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
.form-text  { color: var(--muted); }

.modal-content  { background-color: var(--surface); border: 1px solid var(--border); color: var(--text); }
.modal-header   { border-bottom: 1px solid var(--border); }
.modal-footer   { border-top:    1px solid var(--border); }
.btn-close      { filter: invert(1) grayscale(1); }

.alert {
    border-radius: var(--radius);
    border: none;
    font-size: 0.875rem;
}
.alert-success { background: rgba(34,197,94,0.12);  color: #86efac; }
.alert-danger  { background: rgba(239,68,68,0.12);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.12); color: #fcd34d; }
.alert-info    { background: rgba(6,182,212,0.12);  color: #67e8f9; }

/* ── Badges de estado ── */
.badge-aprobado   { background-color: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-pendiente  { background-color: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-suspendido { background-color: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-admin      { background-color: rgba(59,130,246,0.15); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.badge-usuario    { background-color: rgba(122,154,184,0.12); color: var(--muted); border: 1px solid rgba(122,154,184,0.25); }
.badge-activo     { background-color: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-inactivo   { background-color: rgba(122,154,184,0.12); color: var(--muted); }
.status-badge     { display:inline-block; padding:2px 10px; border-radius:20px; font-size:0.72rem; font-weight:600; }

/* ── Navbar ── */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--navbar);
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
}
.app-navbar .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.app-navbar .brand:hover { color: var(--primary); }
.app-navbar .spacer { flex: 1; }
.app-navbar .nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.82rem;
}
.app-navbar a.nav-link-item {
    color: var(--muted);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    font-size: 0.82rem;
}
.app-navbar a.nav-link-item:hover { background: var(--surface3); color: var(--text); }
.app-navbar a.nav-link-item.active { color: var(--primary); }

/* ── Admin layout ── */
.admin-wrap {
    display: flex;
    min-height: calc(100vh - var(--navbar));
}

.sidebar {
    width: var(--sidebar);
    min-width: var(--sidebar);
    background-color: var(--surface2);
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--navbar);
    height: calc(100vh - var(--navbar));
    overflow-y: auto;
    flex-shrink: 0;
    padding: 1rem 0;
}
.sidebar-brand {
    padding: 0.5rem 1.25rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 0.5rem; }
.sidebar-nav .nav-link {
    color: var(--muted);
    border-radius: 7px;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.sidebar-nav .nav-link:hover  { background: var(--surface3); color: var(--text); }
.sidebar-nav .nav-link.active { background: rgba(59,130,246,0.12); color: var(--primary); font-weight: 600; }
.sidebar-nav .nav-link i      { width: 16px; text-align: center; }

.admin-main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

/* ── Metric cards ── */
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.metric-icon.blue   { background: rgba(59,130,246,0.12); color: var(--primary); }
.metric-icon.green  { background: rgba(34,197,94,0.12);  color: var(--success); }
.metric-icon.yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.metric-icon.red    { background: rgba(239,68,68,0.12);  color: var(--danger); }
.metric-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--text); }
.metric-label { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ── Auth pages ── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.04) 0%, transparent 50%),
        var(--bg);
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.auth-logo .compass-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}
.auth-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
}
.auth-logo p { color: var(--muted); font-size: 0.82rem; margin: 0; }

/* ── Password toggle ── */
.input-group .btn-outline-secondary {
    border-color: var(--border);
    color: var(--muted);
    background: var(--surface2);
}
.input-group .btn-outline-secondary:hover { background: var(--surface3); color: var(--text); }

/* ── Brújula page ── */
.brujula-page {
    min-height: calc(100vh - var(--navbar));
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 0;
}
@media (max-width: 768px) {
    .brujula-page { grid-template-columns: 1fr; }
    .destinos-panel { border-left: none; border-top: 1px solid var(--border); }
}

.compass-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1.5rem;
}

/* ── SVG Compass ── */
.compass-container {
    position: relative;
    width: 280px;
    height: 280px;
}
.compass-ring {
    width: 100%;
    height: 100%;
}
.compass-needle-wrap {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: transform 0.1s ease-out;
}
.compass-data {
    text-align: center;
    min-width: 200px;
}
.compass-heading {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.compass-cardinal {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 700;
    margin-top: 4px;
}
.compass-accuracy {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 6px;
}
.gps-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--surface3);
    color: var(--muted);
}
.gps-status.ok { color: var(--success); background: rgba(34,197,94,0.08); }
.gps-status.error { color: var(--danger); background: rgba(239,68,68,0.08); }
.gps-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* Destino info box */
.destino-info-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    min-width: 260px;
    max-width: 320px;
    text-align: left;
}
.destino-info-box h4 { font-size: 0.9rem; font-weight: 700; margin: 0 0 0.5rem; color: var(--text); }
.destino-stat { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 3px 0; border-bottom: 1px solid var(--border); }
.destino-stat:last-child { border-bottom: none; }
.destino-stat .label { color: var(--muted); }
.destino-stat .value { font-weight: 600; color: var(--primary); }

/* Destinos panel */
.destinos-panel {
    border-left: 1px solid var(--border);
    background: var(--surface2);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--navbar));
    overflow: hidden;
}
.destinos-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}
.destinos-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}
.destinos-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    flex-shrink: 0;
}
.destinos-search i.fa-search { color: var(--muted); font-size: .8rem; }
.destinos-search input {
    flex: 1;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .4rem .9rem;
    font-size: .8rem;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.destinos-search input::placeholder { color: var(--muted); }
.destinos-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.destinos-search button {
    background: none;
    border: none;
    color: var(--muted);
    font-size: .8rem;
    cursor: pointer;
    padding: .2rem .3rem;
    flex-shrink: 0;
}
.destinos-search button:hover { color: var(--danger); }
.destinos-list-empty-search {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--muted);
    font-size: .82rem;
}
.btn-cargar-mas {
    display: block;
    width: 100%;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: .65rem;
    margin-top: .25rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-align: center;
    transition: background .12s, border-color .12s;
}
.btn-cargar-mas:hover { background: var(--surface3); border-color: var(--primary); }
.carga-dot {
    display: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    margin-left: 4px;
    animation: pulso-carga 1s ease-in-out infinite;
}
@keyframes pulso-carga {
    0%, 100% { opacity: .25; transform: scale(.8); }
    50%      { opacity: 1;   transform: scale(1.1); }
}
.destino-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.destino-item:hover { border-color: var(--primary); background: var(--surface3); }
.destino-item.active { border-color: var(--primary); background: rgba(59,130,246,0.07); }
.destino-item h5 { font-size: 0.85rem; font-weight: 600; margin: 0 0 4px; color: var(--text); }
.destino-item .meta { font-size: 0.75rem; color: var(--muted); display: flex; justify-content: space-between; }

/* Nombre del destino: una línea + toque para expandir ── */
.nombre-destino {
    display: flex;
    align-items: baseline;
    gap: .35rem;
    margin: 0 0 4px;
    padding: 2px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(59,130,246,.15);
}
.nombre-destino-txt {
    flex: 1 1 auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.nombre-destino-chevron {
    flex-shrink: 0;
    font-size: .6rem;
    color: var(--muted);
    transition: transform .2s ease;
    margin-left: auto;
    padding-left: .25rem;
}
.nombre-destino:active .nombre-destino-chevron { color: var(--primary); }
.nombre-destino.expandido .nombre-destino-txt {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.nombre-destino.expandido .nombre-destino-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}
.destino-item .dist { color: var(--primary); font-weight: 600; }
.btn-ia {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 6px;
    width: 100%;
}

/* ── IA Chat ── */
.ia-response {
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem;
    font-size: 0.82rem;
    line-height: 1.55;
    margin-top: 0.5rem;
    color: var(--text);
}

/* ── Loading spinner ── */
.spinner-custom {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pendiente page ── */
.pendiente-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.pendiente-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 3rem 2rem;
    text-align: center;
    max-width: 440px;
    width: 100%;
}

/* ── Responsive tweaks ── */
@media (max-width: 900px) {
    .admin-main { padding: 1.25rem; }
    .sidebar { display: none; }
    .admin-wrap { display: block; }
}
@media (max-width: 576px) {
    .auth-card { padding: 1.75rem 1.25rem; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
