/* layout.css - Header, sidebar navigation, main content wrapper */

/* ==================== HEADER STYLES ==================== */
.main-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Header Mobile Logo (visible only on mobile) */
.header-mobile-logo {
    display: none;
    text-decoration: none;
}

.header-mobile-logo img {
    height: 32px;
    width: auto;
}

@media (max-width: 991px) {
    .header-mobile-logo {
        display: flex;
        align-items: center;
        margin-left: 0.75rem;
    }
}

/* Current Page Title in Header */
.current-page-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid #e5e7eb;
}

.current-page-title i {
    font-size: 1.1rem;
    color: var(--eff-primary);
}

.current-page-title span {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2937;
}

@media (max-width: 991px) {
    .current-page-title {
        margin-left: 1rem;
        padding-left: 1rem;
    }

    .current-page-title span {
        font-size: 1rem;
    }
}

.header-logo {
    height: 40px;
    padding: 0;
}

.nav-item .nav-link {
    color: #212529;
    font-size: 1.125rem;
    padding: 1.125rem 1rem;
    position: relative;
}

.nav-item .nav-link:hover {
    color: #198754;
}

.nav-item .nav-link.active {
    color: #198754;
}

.nav-item .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #198754;
}

.draft-badge {
    position: absolute;
    top: 8px;
    right: -2px;
    font-size: 0.65rem;
}

.btn-success {
    background-color: #198754;
    border-color: #198754;
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
}

.profile-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* ==================== SIDEBAR NAVIGATION ==================== */

/* Main Sidebar Container */
.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-width-expanded);
    background: #fff;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: var(--sidebar-transition);
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

/* Collapsed State */
.app-sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.app-sidebar.collapsed .sidebar-text,
.app-sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
    white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

.app-sidebar.collapsed .sidebar-header {
    padding: 1rem 0.75rem;
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-brand {
    justify-content: center;
}

.app-sidebar.collapsed .sidebar-logo {
    margin-right: 0;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    min-height: var(--header-height);
    gap: 0.75rem;
    position: relative;
}

.app-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
}

.app-sidebar.collapsed .sidebar-toggle {
    position: relative;
    right: auto;
}

/* Sidebar Brand (Logo/Avatar) */
.sidebar-brand-container {
    display: flex;
    align-items: center;
    text-decoration: none;
    position: relative;
    height: 40px;
    overflow: hidden;
}

.sidebar-brand-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand-avatar span {
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* Collapsed state */
.app-sidebar.collapsed .sidebar-brand-container {
    width: 40px;
    height: 40px;
    justify-content: center;
}

.sidebar-toggle {
    background: none;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    cursor: pointer;
    transition: var(--sidebar-transition);
    flex-shrink: 0;
    position: absolute;
    right: 1.25rem;
}

.sidebar-toggle:hover {
    background: #f8f9fa;
    color: #198754;
    border-color: #198754;
}

.sidebar-toggle-icon {
    transition: transform 0.3s ease;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin: 0.125rem 0.75rem;
}

/* Sidebar Separators with Labels */
.sidebar-separator {
    margin: 0.4rem 0.75rem 0.15rem 0.75rem;
    padding: 0.35rem 1rem 0.15rem 1rem;
    border-top: 1px solid #e9ecef;
}

.sidebar-separator:first-of-type {
    border-top: none;
    margin-top: 0.15rem;
}

.sidebar-separator-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.app-sidebar.collapsed .sidebar-separator {
    padding: 0.5rem 0;
    margin: 0.5rem 0.75rem;
}

.app-sidebar.collapsed .sidebar-separator-label {
    display: none;
}

.app-sidebar.collapsed .sidebar-separator::after {
    content: '';
    display: block;
    height: 1px;
    background: #e9ecef;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #495057;
    text-decoration: none;
    border-radius: 8px;
    transition: var(--sidebar-transition);
    position: relative;
    overflow: hidden;
}

.sidebar-link:hover {
    background: #f0fff4;
    color: #198754;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.3);
}

.sidebar-link.active .sidebar-icon {
    color: #fff;
}

.sidebar-icon {
    width: 18px;
    font-size: 1rem;
    margin-right: 0.75rem;
    text-align: center;
    flex-shrink: 0;
    color: #6c757d;
    transition: var(--sidebar-transition);
}

.sidebar-link:hover .sidebar-icon {
    color: #198754;
}

.sidebar-text {
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--sidebar-transition);
    white-space: nowrap;
}

.sidebar-badge {
    margin-left: auto;
    background: #dc3545;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    transition: var(--sidebar-transition);
    animation: badge-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 8px 2px rgba(220, 53, 69, 0.3);
    }
}

.app-sidebar.collapsed .sidebar-link {
    overflow: visible;
}

.app-sidebar.collapsed .sidebar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    padding: 1px 4px;
    font-size: 0.55rem;
    min-width: 16px;
    text-align: center;
    z-index: 10;
    border: 2px solid #f8f9fa;
}

.sidebar-badge-new {
    margin-left: auto;
    background: linear-gradient(135deg, #198754, #20c997);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--sidebar-transition);
    animation: new-badge-glow 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.5);
}

@keyframes new-badge-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 5px 0 rgba(25, 135, 84, 0.5);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 12px 3px rgba(32, 201, 151, 0.6);
    }
}

.app-sidebar.collapsed .sidebar-badge-new {
    position: absolute;
    top: 2px;
    right: 2px;
    padding: 1px 4px;
    font-size: 0.5rem;
    z-index: 10;
    border: 2px solid #f8f9fa;
}

/* Sidebar Footer - Profile Section */
.sidebar-footer {
    padding: 0.5rem;
    border-top: 1px solid #e9ecef;
    position: relative;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--sidebar-transition);
    gap: 0.75rem;
}

.sidebar-profile:hover {
    background: #f3f4f6;
}

.sidebar-profile-avatar {
    position: relative;
    flex-shrink: 0;
}

.sidebar-profile-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e9ecef;
}

.sidebar-role-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.sidebar-role-indicator.admin {
    background: #198754;
}

.sidebar-role-indicator.user {
    background: #0d6efd;
}

.sidebar-profile-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-profile-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-role {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
}

.sidebar-profile-more {
    color: #6c757d;
    font-size: 0.85rem;
}

.app-sidebar.collapsed .sidebar-profile-info,
.app-sidebar.collapsed .sidebar-profile-more {
    display: none;
}

.app-sidebar.collapsed .sidebar-profile {
    justify-content: center;
    padding: 0.5rem;
}

/* Sidebar Profile Menu */
.sidebar-profile-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0.75rem;
    right: 0.75rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.sidebar-profile-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sidebar-profile-menu hr {
    margin: 0.25rem 0;
    border-color: #e9ecef;
}

.sidebar-profile-menu-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    color: #495057;
    text-decoration: none;
    font-size: 0.875rem;
    gap: 0.75rem;
    transition: background 0.15s;
}

.sidebar-profile-menu-item:hover {
    background: #f8f9fa;
    color: #212529;
}

.sidebar-profile-menu-item i {
    width: 18px;
    text-align: center;
    color: #6c757d;
}

.sidebar-profile-menu-item.logout {
    color: #dc3545;
}

.sidebar-profile-menu-item.logout i {
    color: #dc3545;
}

.sidebar-profile-menu-item.logout:hover {
    background: #fff5f5;
}

.app-sidebar.collapsed .sidebar-profile-menu {
    left: calc(100% + 10px);
    bottom: 0;
    right: auto;
    min-width: 200px;
}

/* Tooltip for Collapsed State */
.app-sidebar.collapsed .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #212529;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1050;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-sidebar.collapsed .sidebar-link::before {
    content: '';
    position: absolute;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #212529;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.app-sidebar.collapsed .sidebar-link:hover::after,
.app-sidebar.collapsed .sidebar-link:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #495057;
    padding: 0.5rem;
    margin-right: 0.5rem;
    cursor: pointer;
    display: none;
}

.mobile-menu-toggle:hover {
    color: #198754;
}

/* Main Content Wrapper */
.main-content-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin-left: var(--sidebar-width-expanded);
    transition: var(--sidebar-transition);
}

.sidebar-collapsed .main-content-wrapper {
    margin-left: var(--sidebar-width-collapsed);
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.mobile-open {
        transform: translateX(0);
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .header-logo-link {
        display: flex !important;
    }

    .main-content-wrapper {
        margin-left: 0 !important;
    }

    .main-footer {
        left: 0 !important;
    }
}

@media (min-width: 992px) {
    .header-logo-link {
        display: none;
    }
}

/* ==================== MAIN CONTENT LAYOUT ==================== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding-bottom: 50px; /* Space for fixed footer */
}

/* Allow scrolling on pages that need it */
.main-content:has(#page-dashboard.active),
.main-content:has(#page-deceased.active),
.main-content:has(#page-claims.active),
.main-content:has(#page-drafts.active),
.main-content:has(#page-analytics.active),
.main-content:has(#page-reports.active),
.main-content:has(#page-admin.active),
.main-content:has(#page-create-claim.active) {
    overflow-y: auto;
}

.page-section {
    display: none;
    width: 100%;
    height: 100%;
}

.page-section.active {
    display: flex;
    flex-direction: column;
}

/* Shimmer loading state for lazy-loaded pages */
.page-section.active:empty::before {
    content: '';
    display: block;
    width: calc(100% - 40px);
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: pageShimmer 1.5s infinite;
    border-radius: 8px;
    margin: 20px;
}

@keyframes pageShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.page-section.flex-section.active {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

#page-create-claim.active {
    padding-top: 1.5rem;
    flex-direction: row;
}

#page-create-claim .form-area {
    padding-top: 1.5rem;
    overflow-y: visible;
    margin-left: 280px; /* Account for fixed step-nav width */
}

#page-create-claim .step-nav {
    padding-top: 1.5rem;
}

/* Full-height content containers */
#page-reports.active .dashboard-content,
#page-drafts.active .dashboard-content,
#page-deceased.active .dashboard-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Claims page - no overflow hidden to allow sticky */
#page-claims.active .dashboard-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#page-reports .reports-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#page-reports .reports-table-container,
#page-claims .table-container,
#page-deceased .table-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#page-reports .reports-table-wrap,
#page-claims .table-container,
#page-deceased .table-container {
    flex: 1;
    overflow-y: auto;
}

/* Drafts grid takes full height */
#page-drafts .drafts-grid {
    flex: 1;
    overflow-y: auto;
    align-content: flex-start;
}

/* Make tables fill available space with sticky headers */
#page-claims .table-container table,
#page-deceased .table-container table {
    margin-bottom: 0;
}

#page-claims .table-container table thead,
#page-deceased .table-container table thead {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
}
