/* Geekscar Tech Hub - Custom Styles (Dark Theme) */

:root {
    /* ===== Paleta de marca (prueba) =====
       1. Midnight Static  #1B1C20  (fondo base)
       2. Regal Anchor     #144EA0  (primario / acento)
       3. Snow White       #FFFAFA  (texto / superficies claras)
       Para revertir al tema anterior, restaurar los valores comentados. */
    --midnight-static: #1B1C20;
    --regal-anchor: #144EA0;
    --snow-white: #FFFAFA;
    /* Tonos derivados para superficies y estados */
    --midnight-raised: #26272d;   /* superficie elevada (hover, cards sutiles) */
    --regal-anchor-hover: #1a5fc0;
    --regal-anchor-rgb: 20, 78, 160;

    --sidebar-width: 250px;
    --sidebar-bg: var(--midnight-static);       /* antes #1a1d23 */
    --sidebar-hover: var(--midnight-raised);    /* antes #2a2d35 */
    --sidebar-active: var(--regal-anchor);      /* antes #0d6efd */
    --body-bg: var(--midnight-static);          /* antes #0f1117 */
    --card-bg: #202127;                          /* card ligeramente sobre el fondo */
}

/* Sobrescribir el primario de Bootstrap. Va en [data-bs-theme=dark] para
   ganar especificidad al tema oscuro de Bootstrap 5.3 (CDN). */
:root,
[data-bs-theme="dark"] {
    --bs-primary: var(--regal-anchor);
    --bs-primary-rgb: var(--regal-anchor-rgb);
    --bs-link-color: #4d8be0;                    /* azul mas claro para legibilidad sobre oscuro */
    --bs-link-color-rgb: 77, 139, 224;
    --bs-link-hover-color: #7aa9e8;
    --bs-link-hover-color-rgb: 122, 169, 232;
    /* Snow White como texto base; Midnight Static como fondo */
    --bs-body-bg: var(--midnight-static);
    --bs-body-bg-rgb: 27, 28, 32;
    --bs-body-color: var(--snow-white);
    --bs-body-color-rgb: 255, 250, 250;
    --bs-emphasis-color: var(--snow-white);
}

/* Botones y enlaces primarios con Regal Anchor */
.btn-primary {
    --bs-btn-bg: var(--regal-anchor);
    --bs-btn-border-color: var(--regal-anchor);
    --bs-btn-hover-bg: var(--regal-anchor-hover);
    --bs-btn-hover-border-color: var(--regal-anchor-hover);
    --bs-btn-active-bg: var(--regal-anchor-hover);
    --bs-btn-active-border-color: var(--regal-anchor-hover);
    --bs-btn-disabled-bg: var(--regal-anchor);
    --bs-btn-disabled-border-color: var(--regal-anchor);
}
.btn-outline-primary {
    --bs-btn-color: #4d8be0;
    --bs-btn-border-color: var(--regal-anchor);
    --bs-btn-hover-bg: var(--regal-anchor);
    --bs-btn-hover-border-color: var(--regal-anchor);
    --bs-btn-active-bg: var(--regal-anchor);
    --bs-btn-active-border-color: var(--regal-anchor);
}
.text-primary { color: var(--regal-anchor) !important; }
.bg-primary { background-color: var(--regal-anchor) !important; }
a { color: var(--bs-link-color); }
a:hover { color: var(--bs-link-hover-color); }

body {
    background-color: var(--body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);  /* fixed width, never shrink or grow */
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    position: sticky;
    top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Prevent main content from overflowing and pushing the sidebar */
#main-content {
    min-width: 0;
}

.sidebar .nav-link {
    color: #9ca3af;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    color: #e5e7eb;
    background-color: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: var(--sidebar-active);
}

.sidebar .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 8px;
}

.sidebar-header h5 {
    color: #e5e7eb;
}

.nav-header {
    padding: 0 14px;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
}

.card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Auth pages */
.auth-wrapper {
    background: linear-gradient(135deg, var(--body-bg) 0%, #1a1d23 100%);
}

.auth-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

/* Icon boxes */
.icon-box {
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
}

/* Status badges */
.badge-pendiente {
    background-color: #fbbf24;
    color: #1a1d23;
}

.badge-completada {
    background-color: #34d399;
    color: #1a1d23;
}

.badge-cancelada {
    background-color: #f87171;
    color: #fff;
}

/* Appointment cards */
.appointment-card {
    border-left: 4px solid var(--sidebar-active);
    transition: transform 0.2s ease;
}

.appointment-card:hover {
    transform: translateX(4px);
}

.appointment-card.type-estudio {
    border-left-color: #8b5cf6;
}

.appointment-card.type-resurtido {
    border-left-color: #f59e0b;
}

/* Medication card */
.medication-card.inactive {
    opacity: 0.6;
}

/* Chronic + active medications need special attention */
.medication-card.chronic-active {
    position: relative;
    overflow: hidden;
    border-left: 4px solid #fbbf24 !important;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3), 0 4px 16px rgba(251, 191, 36, 0.15) !important;
}

.medication-card.chronic-active:hover {
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.5), 0 6px 20px rgba(251, 191, 36, 0.25) !important;
}

.chronic-flag {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    color: #1a1d23;
    font-size: 0.7rem;
    font-weight: bold;
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.3px;
}

.chronic-flag i {
    animation: chronic-pulse 2s ease-in-out infinite;
}

@keyframes chronic-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--body-bg);
}

::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* ==================== GLOBAL SEARCH ==================== */
.global-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    max-height: 340px;
    overflow-y: auto;
}

.global-search-results.show {
    display: block;
}

.global-search-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    color: #e5e7eb;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.global-search-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

/* ==================== MOBILE TOP BAR ==================== */
.mobile-topbar {
    display: none;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1035;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 16px;
}

.mobile-topbar .btn-link {
    color: #e5e7eb;
    font-size: 1.6rem;
    line-height: 1;
    text-decoration: none;
}

.mobile-brand {
    font-weight: 600;
    color: #e5e7eb;
    font-size: 1rem;
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ==================== RESPONSIVE (tablet & phone) ==================== */
@media (max-width: 991.98px) {
    /* Show mobile top bar */
    .mobile-topbar {
        display: flex;
    }

    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        overflow-y: auto;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    /* Main content full width, less padding */
    #main-content {
        padding: 16px !important;
        width: 100%;
    }

    /* Assistant on mobile: bottom-right, below the drawer */
    #assistant-widget {
        bottom: 16px;
        right: 16px;
        z-index: 1030;
    }

    .assistant-mascot {
        width: 50px;
        height: 50px;
    }

    .assistant-face {
        font-size: 1.5rem;
    }

    .mollete-avatar {
        width: 36px;
        height: 36px;
    }

    .assistant-bubble {
        max-width: 240px;
        min-width: 180px;
    }

    /* Headings a bit smaller */
    h3.fw-bold {
        font-size: 1.4rem;
    }
}

/* Extra small phones */
@media (max-width: 575.98px) {
    #main-content {
        padding: 12px !important;
    }

    /* Stack modal buttons full width */
    .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* Reduce card body padding */
    .card-body {
        padding: 1rem;
    }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}


/* Entry cards - clickable */
.entry-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Fix dropdown menu appearing behind sibling cards */
.dropdown-menu.show {
    z-index: 1060;
}

/* Elevate the card that has an open dropdown above sibling cards */
.card:has(.dropdown-menu.show) {
    position: relative;
    z-index: 1055;
}

/* Border dashed for upload area */
.border-dashed {
    border: 2px dashed rgba(255, 255, 255, 0.15) !important;
    background: rgba(255, 255, 255, 0.02);
}


/* ==================== VIRTUAL ASSISTANT ==================== */
#assistant-widget {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.assistant-mascot {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--regal-anchor) 0%, #0e3873 100%);
    border: none;
    box-shadow: 0 4px 16px rgba(var(--regal-anchor-rgb), 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.assistant-mascot:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.6);
}

.assistant-mascot:active {
    transform: scale(0.95);
}

.assistant-face {
    font-size: 1.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: assistant-bounce 3s ease-in-out infinite;
}

/* Avatar SVG de Mollete (labradoodle) dentro del boton del asistente */
.mollete-avatar {
    width: 44px;
    height: 44px;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

.assistant-mascot {
    /* Fondo teal para contrastar con el pelaje blanco y el durazno del avatar */
    background: linear-gradient(135deg, #1a9c94 0%, #12716b 100%);
    box-shadow: 0 4px 16px rgba(18, 113, 107, 0.45);
}

.assistant-mascot:hover {
    box-shadow: 0 6px 20px rgba(18, 113, 107, 0.65);
}

@keyframes assistant-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.assistant-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--body-bg);
}

.assistant-bubble {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    max-width: 280px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    position: relative;
    display: none;
    animation: assistant-pop 0.25s ease;
}

.assistant-bubble.show {
    display: block;
}

@keyframes assistant-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.assistant-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: var(--card-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

.assistant-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.assistant-bubble-close:hover {
    color: #e5e7eb;
}

.assistant-bubble-content {
    font-size: 0.9rem;
    padding-right: 16px;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.15s ease;
}

.assistant-bubble-content .insight-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.assistant-bubble-content .insight-icon.priority-1 { color: #f87171; }
.assistant-bubble-content .insight-icon.priority-2 { color: #fbbf24; }
.assistant-bubble-content .insight-icon.priority-3 { color: #60a5fa; }

.assistant-bubble-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.assistant-nav-counter {
    font-size: 0.75rem;
    color: #9ca3af;
}


/* Timeline for medication schedule */
.timeline-entry {
    position: relative;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--regal-anchor);
    margin-top: 8px;
    flex-shrink: 0;
    position: relative;
}

.timeline-dot::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 5px;
    width: 2px;
    height: calc(100% + 12px);
    background: rgba(13, 110, 253, 0.2);
}

.timeline-entry:last-child .timeline-dot::after {
    display: none;
}


/* ==================== TOUCH-FRIENDLY (pantalla touch) ==================== */

/* Remove tap delay and prevent accidental double-tap zoom on interactive elements */
.btn, .nav-link, .dropdown-item, .form-select, .form-control,
.assistant-mascot, .nav-tabs .nav-link, .page-link, a.card, .entry-card, .study-card {
    touch-action: manipulation;
}

/* Minimum comfortable tap target for buttons */
.btn {
    min-height: 40px;
}

/* Icon-only small buttons: keep them square and tappable */
.btn-sm {
    min-height: 36px;
    min-width: 36px;
}

/* Small icon buttons that override padding (p-0 px-1) still get a tap area */
.table .btn-sm,
.btn-sm.p-0 {
    min-height: 34px;
    min-width: 34px;
}

/* More breathing room between grouped action buttons */
.btn-group-sm > .btn {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

.card .btn-group .btn {
    margin: 0;
}

/* Space out card action button groups a little */
.medication-card .btn-group .btn + .btn,
.appointment-card .btn-group .btn + .btn {
    margin-left: 2px;
}

/* Larger dropdown menu items (three-dots menus) */
.dropdown-menu {
    padding: 6px;
}

.dropdown-item {
    padding: 10px 14px;
    border-radius: 6px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Filter selects/inputs: comfortable height even when -sm */
.form-select-sm, .form-control-sm {
    min-height: 38px;
    font-size: 0.9rem;
}

.form-select, .form-control {
    min-height: 42px;
}

/* Sidebar nav links a touch taller */
.sidebar .nav-link {
    padding: 12px 14px;
}

/* Modal close and bubble close bigger hit area */
.btn-close {
    padding: 12px;
}

.assistant-bubble-close {
    padding: 8px;
    font-size: 1.3rem;
}

/* Tabs easier to tap */
.nav-tabs .nav-link {
    padding: 10px 16px;
}

/* Checkboxes/switches larger */
.form-check-input {
    width: 1.3em;
    height: 1.3em;
    margin-top: 0.15em;
}

/* Enlarge assistant nav arrows */
.assistant-bubble-nav .btn {
    min-height: 34px;
    min-width: 34px;
    font-size: 1.1rem;
}

/* On devices whose primary pointer is touch, scale up a bit more */
@media (pointer: coarse) {
    .btn-sm {
        min-height: 40px;
        min-width: 40px;
    }
    .table td, .table th {
        padding-top: 12px;
        padding-bottom: 12px;
    }
    .dropdown-item {
        min-height: 48px;
    }
}
