/**
 * Sidebar Navigation Styles
 * Memorial Management System
 */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1a1d29;
    --sidebar-border: #2d3748;
    --sidebar-text: #a0aec0;
    --sidebar-text-hover: #fff;
    --sidebar-accent: #C8A96A;
    --header-height: 60px;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-x: hidden;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--header-height);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar-logo {
    height: 40px;
    width: auto;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(200, 169, 106, 0.1);
    color: var(--sidebar-accent);
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 2px;
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 0.25rem;
    border-bottom: 1px solid rgba(45, 55, 72, 0.5);
}

.sidebar-section:last-child {
    border-bottom: none;
}

/* Accordion Section Header */
.sidebar-section-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 0;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-section-header:hover {
    background: rgba(200, 169, 106, 0.08);
    color: var(--sidebar-text-hover);
}

.sidebar-section-header[aria-expanded="true"] {
    color: var(--sidebar-accent);
}

.sidebar-section-header .section-icon {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 0.9rem;
    color: var(--sidebar-accent);
    flex-shrink: 0;
}

.sidebar-section-header span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-section-header .accordion-arrow {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    transition: transform 0.3s ease;
    margin-left: auto;
}

.sidebar-section-header[aria-expanded="true"] .accordion-arrow {
    transform: rotate(180deg);
}

/* Accordion Content */
.sidebar-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar-accordion-content.show {
    max-height: 600px;
    transition: max-height 0.4s ease-in;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    padding-left: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem 0.5rem 2rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 2px solid transparent;
    font-size: 0.85rem;
}

.sidebar-link i {
    width: 20px;
    margin-right: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    background: rgba(200, 169, 106, 0.08);
    color: var(--sidebar-text-hover);
    border-left-color: rgba(200, 169, 106, 0.3);
}

.sidebar-link.active {
    background: rgba(200, 169, 106, 0.15);
    color: var(--sidebar-accent);
    border-left-color: var(--sidebar-accent);
    font-weight: 500;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-footer-link:hover {
    background: rgba(200, 169, 106, 0.1);
    color: var(--sidebar-accent);
}

.sidebar-footer-link i {
    margin-right: 0.5rem;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Top Header */
.top-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 1.5rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
    z-index: 1030;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--sidebar-text-hover);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
}

.header-icon-link:hover {
    background: rgba(200, 169, 106, 0.1);
    color: var(--sidebar-accent);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
    background: var(--sidebar-accent);
    color: #000;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.header-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(200, 169, 106, 0.1);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.header-user-btn:hover {
    background: rgba(200, 169, 106, 0.2);
    color: var(--sidebar-text-hover);
    border-color: var(--sidebar-accent);
}

.header-user-btn::after {
    margin-left: 0.25rem;
}

/* Flash Messages */
.flash-messages {
    padding: 1rem 1.5rem 0;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    background: #0d0d0d;
}

/* Main Footer */
.main-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
}

.footer-content {
    text-align: center;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile Styles */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
}

/* Tablet Adjustments */
@media (min-width: 992px) and (max-width: 1199.98px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .sidebar-link {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
    
    .sidebar-section-header {
        font-size: 0.65rem;
        padding: 0.75rem 0.75rem 0.4rem;
    }
}

/* Large Screen */
@media (min-width: 1400px) {
    :root {
        --sidebar-width: 280px;
    }
}

/* Collapsed Sidebar */
@media (min-width: 992px) {
    .sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }
    
    .sidebar.collapsed .sidebar-link span,
    .sidebar.collapsed .sidebar-section-header,
    .sidebar.collapsed .sidebar-footer-link span,
    .sidebar.collapsed .sidebar-logo {
        display: none;
    }
    
    .sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding: 0.75rem;
    }
    
    .sidebar.collapsed .sidebar-link i {
        margin-right: 0;
        font-size: 1.1rem;
    }
    
    .sidebar.collapsed .sidebar-header {
        justify-content: center;
        padding: 1rem 0.5rem;
    }
    
    .sidebar.collapsed .sidebar-brand::after {
        content: "MM";
        color: var(--sidebar-accent);
        font-weight: 700;
        font-size: 1.2rem;
    }
    
    .sidebar.collapsed .sidebar-section {
        padding: 0.25rem 0;
    }
    
    .sidebar.collapsed .sidebar-footer-link {
        justify-content: center;
        padding: 0.75rem;
    }
    
    .sidebar.collapsed ~ .main-wrapper {
        margin-left: var(--sidebar-collapsed-width);
    }
    
    /* Tooltip on hover for collapsed sidebar */
    .sidebar.collapsed .sidebar-link {
        position: relative;
    }
    
    .sidebar.collapsed .sidebar-link:hover::after {
        content: attr(data-title);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        background: #333;
        color: #fff;
        padding: 0.5rem 0.75rem;
        border-radius: 4px;
        font-size: 0.85rem;
        white-space: nowrap;
        z-index: 1050;
        margin-left: 10px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }
}

/* Theme Toggle in Header */
.top-header .theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dropdown Menu Styling */
.header-right .dropdown-menu {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 200px;
}

.header-right .dropdown-header {
    color: var(--sidebar-accent);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem 0.5rem;
}

.header-right .dropdown-item {
    color: var(--sidebar-text);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

.header-right .dropdown-item:hover {
    background: rgba(200, 169, 106, 0.1);
    color: var(--sidebar-text-hover);
}

.header-right .dropdown-divider {
    border-color: var(--sidebar-border);
    margin: 0.5rem 0;
}

/* ADA Focus States */
.sidebar-link:focus,
.header-icon-link:focus,
.header-user-btn:focus,
.sidebar-toggle:focus {
    outline: 3px solid var(--sidebar-accent);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .sidebar {
        border-right-width: 2px;
    }
    
    .sidebar-link.active {
        border-left-width: 4px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay,
    .sidebar-link,
    .header-user-btn {
        transition: none;
    }
}
