/**
 * Nyalife HMS - Fresh Dashboard Styles
 * This file contains all dashboard-specific styles and MUST be loaded LAST
 * to override any conflicting legacy styles.
 */

/* ============================================
   CRITICAL Z-INDEX HIERARCHY
   All values are 10000+ to override legacy CSS
   ============================================ */

:root {
    --nyl-base-z: 1;
    --nyl-content-z: 10;
    --nyl-sidebar-z: 100;
    --nyl-dropdown-z: 500;
    --nyl-modal-overlay-z: 99999;
    --nyl-modal-panel-z: 100000;
}

/* ============================================
   RESET MAIN CONTENT STACKING CONTEXT
   ============================================ */

/* Remove any stacking context from main-content that could trap modals */
.main-content {
    position: relative;
    z-index: var(--nyl-content-z);
    /* DO NOT set transform, filter, or will-change here */
}

/* ============================================
   SIDEBAR - FRESH STYLES
   ============================================ */

.nyalife-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 260px;
    height: 100vh !important;
    background: linear-gradient(180deg, #e91e63 0%, #c2185b 100%);
    color: white;
    z-index: var(--nyl-sidebar-z) !important;
    transition: width 0.3s ease;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Collapsed State */
.nyalife-sidebar.collapsed {
    width: 70px;
}

.nyalife-sidebar.collapsed .sidebar-text,
.nyalife-sidebar.collapsed .logo-text,
.nyalife-sidebar.collapsed .logo-brand,
.nyalife-sidebar.collapsed .logo-subtitle {
    display: none !important;
    opacity: 0 !important;
    width: 0 !important;
    visibility: hidden !important;
}

.nyalife-sidebar.collapsed .sidebar-link {
    justify-content: center !important;
    padding: 14px 0 !important;
    text-align: center !important;
}

.nyalife-sidebar.collapsed .sidebar-icon {
    margin: 0 auto !important;
}

.nyalife-sidebar.collapsed .sidebar-toggle-btn {
    right: 50% !important;
    transform: translateX(50%) !important;
}

.nyalife-sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Toggle Button */
.sidebar-toggle-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e91e63;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: 10px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-img {
    max-width: 180px;
    max-height: 45px;
    object-fit: contain;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

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

.sidebar-menu-item {
    margin-bottom: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.25s ease;
    font-weight: 500;
    font-size: 0.9rem;
    gap: 12px;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.sidebar-link.active {
    background: white;
    color: #e91e63;
}

.sidebar-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-text {
    flex: 1;
    white-space: nowrap;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.has-sidebar .main-content {
    margin-left: 260px;
    min-height: 100vh;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 30px;
    transition: margin-left 0.3s ease;
    box-sizing: border-box;
    position: relative;
    z-index: var(--nyl-content-z);
}

.has-sidebar.sidebar-collapsed .main-content,
.sidebar-collapsed .main-content {
    margin-left: 70px;
}

body.has-sidebar {
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

/* ============================================
   INFO MODAL - CUSTOM PORTAL STYLES
   Override everything with high specificity
   ============================================ */

.info-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: var(--nyl-modal-overlay-z) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px) !important;
}

.info-modal-panel {
    position: relative !important;
    z-index: var(--nyl-modal-panel-z) !important;
    background: white !important;
    border-radius: 1rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35) !important;
    max-width: 80rem !important;
    width: 100% !important;
    max-height: 90vh !important;
    overflow: hidden !important;
}

/* Make sure modal panel is interactive */
.info-modal-panel,
.info-modal-panel * {
    pointer-events: auto !important;
}

.info-modal-inner {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 500px;
    max-height: 90vh;
}

.info-modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1.25rem;
    z-index: 10;
    padding: 0.5rem;
    transition: color 0.2s;
}

.info-modal-close:hover {
    color: #6b7280;
}

.info-modal-sidebar {
    width: 280px;
    background: #f9fafb;
    padding: 2rem;
    border-right: 1px solid #f3f4f6;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.info-modal-header {
    margin-bottom: 2rem;
}

.info-modal-subtitle {
    color: #ec4899;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.info-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
    margin: 0;
}

.info-modal-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-modal-tab {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
    width: 100%;
    transition: all 0.2s;
    background: transparent;
    color: #6b7280;
}

.info-modal-tab:hover {
    background: #f3f4f6;
}

.info-modal-tab.active {
    background: white;
    color: #ec4899;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.info-modal-tab i {
    color: #9ca3af;
}

.info-modal-tab.active i {
    color: #ec4899;
}

.info-modal-back {
    margin-top: auto;
    padding-top: 2rem;
}

.info-modal-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0;
    transition: color 0.2s;
}

.info-modal-back-btn:hover {
    color: #6b7280;
}

.info-modal-back-btn i {
    font-size: 0.75rem;
}

.info-modal-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    background: white;
}

/* Mobile responsive for modal */
@media (max-width: 768px) {
    .info-modal-inner {
        flex-direction: column;
    }

    .info-modal-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #f3f4f6;
        padding: 1.5rem;
    }

    .info-modal-content {
        padding: 1.5rem;
    }
}

/* ============================================
   HEADLESSUI DIALOG FIXES
   ============================================ */

[data-headlessui-portal] {
    position: fixed !important;
    inset: 0 !important;
    z-index: var(--nyl-modal-overlay-z) !important;
}

[role="dialog"] {
    z-index: var(--nyl-modal-overlay-z) !important;
}

/* ============================================
   BOOTSTRAP MODAL OVERRIDES
   ============================================ */

.modal {
    z-index: var(--nyl-modal-overlay-z) !important;
}

.modal-backdrop {
    z-index: calc(var(--nyl-modal-overlay-z) - 1) !important;
}

.modal-dialog {
    z-index: calc(var(--nyl-modal-overlay-z) + 1) !important;
}

.modal-content {
    z-index: calc(var(--nyl-modal-overlay-z) + 2) !important;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .nyalife-sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

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

    .nyalife-sidebar.collapsed {
        width: 260px;
    }
    
    .nyalife-sidebar.collapsed .sidebar-text,
    .nyalife-sidebar.collapsed .logo-text {
        display: block !important;
        opacity: 1 !important;
        width: auto !important;
        visibility: visible !important;
    }

    .nyalife-sidebar.collapsed .sidebar-link {
        justify-content: flex-start !important;
        padding: 13px 16px !important;
    }

    .has-sidebar .main-content,
    .sidebar-collapsed .main-content {
        margin-left: 0;
        padding: 20px 15px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--nyl-sidebar-z) - 1);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar-toggle-btn {
        display: none;
    }

    .sidebar-toggle-header {
        display: flex;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 90;
        background: white;
        border: none;
        border-radius: 10px;
        width: 42px;
        height: 42px;
        align-items: center;
        justify-content: center;
        color: #e91e63;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.nyalife-sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.nyalife-sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
}
