/* ==========================================================================
   ATEMPO — APP SHELL Y LAYOUT DEL PANEL ADMINISTRATIVO
   ========================================================================== */

#app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-main);
}

#sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    background-color: var(--color-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 240ms cubic-bezier(0.16, 1, 0.3, 1), min-width 240ms cubic-bezier(0.16, 1, 0.3, 1), max-width 240ms cubic-bezier(0.16, 1, 0.3, 1), transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 1px 0 3px rgba(23, 22, 20, 0.02);
}

/* Sidebar colapsado en escritorio */
@media (min-width: 769px) {
    #sidebar.collapsed {
        width: 72px;
        min-width: 72px;
        max-width: 72px;
    }

    #sidebar .sidebar-logo-container {
        transition: padding 240ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    #sidebar.collapsed .sidebar-logo-container {
        padding: 0.75rem 0.25rem;
    }

    #sidebar.collapsed .sidebar-logo-full {
        display: none !important;
    }

    #sidebar.collapsed .sidebar-logo-compact {
        display: block !important;
        max-height: 2rem;
        max-width: 40px;
    }

    #sidebar:not(.collapsed) .sidebar-logo-compact {
        display: none !important;
    }

    #sidebar:not(.collapsed) .sidebar-logo-full {
        display: block !important;
    }

    #sidebar-company-info {
        transition: max-height 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease, padding 240ms cubic-bezier(0.16, 1, 0.3, 1), border-color 180ms ease;
        overflow: hidden;
        max-height: 80px;
        opacity: 1;
    }

    #sidebar.collapsed #sidebar-company-info {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-bottom-color: transparent;
        pointer-events: none;
    }

    #sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding: 0.65rem 0;
        margin: 0.25rem 0.5rem;
    }

    #sidebar.collapsed .sidebar-link i {
        margin-right: 0;
    }

    .sidebar-label {
        display: inline-block;
        overflow: hidden;
        white-space: nowrap;
        min-width: 0;
        max-width: 180px;
        opacity: 1;
        transform: translateX(0);
        transition: max-width 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease, transform 180ms ease;
    }

    #sidebar.collapsed .sidebar-label {
        min-width: 0;
        max-width: 0;
        opacity: 0;
        transform: translateX(-6px);
        pointer-events: none;
    }

    #logout-btn {
        transition: background-color 140ms ease, color 140ms ease, padding 240ms cubic-bezier(0.16, 1, 0.3, 1);
        white-space: nowrap;
        overflow: hidden;
    }

    #sidebar.collapsed #logout-btn {
        justify-content: center;
        padding: 0.5rem 0;
    }

    #logout-btn i {
        transition: margin-right 240ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    #sidebar.collapsed #logout-btn i {
        margin-right: 0;
    }

    #sidebar.collapsed #logout-btn .sidebar-label {
        max-width: 0;
        opacity: 0;
        transform: translateX(-6px);
        pointer-events: none;
    }
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-main);
}

#topbar {
    height: 64px;
    background-color: var(--color-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
    box-shadow: var(--shadow-xs);
}

#page-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 639px) {
    #page-content {
        padding: 0.875rem 0.75rem;
    }
}

.overflow-y-auto,
.overflow-x-auto {
    scroll-behavior: smooth;
}

/* Enlaces de navegación lateral */
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    margin: 0.2rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--color-gray-medium);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: background-color 140ms ease, color 140ms ease, padding 240ms cubic-bezier(0.16, 1, 0.3, 1), margin 240ms cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    background-color: var(--bg-subtle);
    color: var(--color-black-carbon);
}

.sidebar-link.active {
    background-color: var(--color-black-carbon);
    color: var(--color-white);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(23, 22, 20, 0.12);
}

.sidebar-link.active i {
    color: var(--color-brand-yellow);
}

.sidebar-link i {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: margin-right 240ms cubic-bezier(0.16, 1, 0.3, 1), color 140ms ease;
}

/* Cajón móvil del Sidebar */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 40;
        width: 260px !important;
        min-width: 260px !important;
        max-width: 260px !important;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(23, 22, 20, 0.2);
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background-color: rgba(23, 22, 20, 0.5);
        backdrop-filter: blur(2px);
        z-index: 30;
    }
    #sidebar-overlay.open {
        display: block;
    }

    /* Acciones del topbar en móvil: paridad dimensional estricta */
    #topbar {
        padding: 0 1rem;
    }
    #topbar #page-title {
        font-size: 1.125rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #topbar-actions .btn,
    .topbar-actions-container .btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8125rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Agenda View */
.agenda-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 1rem;
}

.agenda-time-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
}

.agenda-time-slot {
    height: 60px;
    position: relative;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: right;
    padding-right: 1rem;
}

.agenda-events-column {
    position: relative;
    border-left: 1px solid var(--border-color);
    background-image: linear-gradient(var(--border-subtle) 1px, transparent 1px);
    background-size: 100% 60px;
}

.agenda-event {
    position: absolute;
    left: 8px;
    right: 8px;
    background-color: var(--color-white);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--color-brand-brown);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.agenda-event:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background-color: #FDFDFC;
    border-color: var(--color-black-carbon);
}

/* Agenda Reference Strip & Cards */
.day-pill-card {
    min-width: 0;
    flex: 1 1 0%;
    max-width: 72px;
    padding: 0.45rem 0.15rem 0.55rem 0.15rem;
    border-radius: 0.75rem;
    border: 1px solid #DCDCD6;
    background-color: #F3F3F0;
    text-align: center;
    cursor: pointer;
    transition: all 140ms ease;
    position: relative;
    user-select: none;
    box-shadow: var(--shadow-xs);
    overflow: visible;
}

@media (min-width: 640px) {
    .day-pill-card {
        min-width: 54px;
        padding: 0.625rem 0.35rem 0.75rem 0.35rem;
        border-radius: 0.875rem;
    }
}

.day-pill-card:hover:not(.selected) {
    border-color: #BDBDB2;
    background-color: #EAEAE5;
}

.day-pill-card.selected {
    background-color: var(--color-brand-brown, #572C19) !important;
    color: var(--color-white) !important;
    border-color: var(--color-brand-brown, #572C19) !important;
    box-shadow: 0 4px 12px rgba(87, 44, 25, 0.28);
}

.day-pill-card.selected .day-name {
    color: #F6F5F2 !important;
}

.day-pill-card.selected .day-num {
    color: #FFFFFF !important;
}

.day-pill-card .day-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6875rem;
    font-weight: 800;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #FFF2BA;
    color: #171614;
    border: 1px solid #EADB8F;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.day-pill-card.selected .day-badge {
    background-color: #FFFFFF !important;
    color: #572C19 !important;
    border-color: #FFFFFF !important;
}

.nav-arrow-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #DCDCD6;
    border-radius: 0.5rem;
    background-color: #F3F3F0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #6B6862;
    transition: all 120ms ease;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}

.nav-arrow-btn:hover {
    border-color: #BDBDB2;
    color: #171614;
    background-color: #EAEAE5;
}

/* ==========================================================================
   DASHBOARD — CONTRASTE VISIBLE DE TARJETAS (#F3F3F0 / #DCDCD6)
   ========================================================================== */

#dashboard-stats .card {
    background-color: #F3F3F0;
    border-color: #DCDCD6;
    box-shadow: var(--shadow-xs);
}

#next-appointments-list .next-appointment-card {
    background-color: #F3F3F0;
    border: 1px solid #DCDCD6;
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

#next-appointments-list .next-appointment-card:hover {
    background-color: #EAEAE5;
    border-color: #BDBDB2;
}

.quick-action-btn {
    background-color: #F3F3F0;
    border: 1px solid #DCDCD6;
    transition: all 140ms ease;
}

.quick-action-btn:hover {
    background-color: #EAEAE5;
    border-color: #171614;
}

/* ==========================================================================
   NOTIFICACIONES INTERNAS DE PANEL (COMPANY NOTIFICATIONS)
   ========================================================================== */

#notifications-dropdown {
    transform-origin: top right;
    transition: opacity 150ms ease, transform 150ms ease;
}

#notifications-badge {
    animation: badge-pop 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes badge-pop {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.notif-item {
    transition: background-color 140ms ease, border-color 140ms ease;
}

.notif-item:active {
    background-color: #F5DCD0;
}

/* Resaltado temporal en Agenda al abrir desde una notificación */
.agenda-appointment-card.ring-2 {
    scroll-margin-top: 100px;
    animation: agenda-highlight 1.5s ease-in-out infinite alternate;
}

@keyframes agenda-highlight {
    0% {
        box-shadow: 0 0 0 2px #572C19, 0 4px 12px rgba(87, 44, 25, 0.15);
    }
    100% {
        box-shadow: 0 0 0 4px #87472A, 0 6px 16px rgba(87, 44, 25, 0.25);
    }
}

