/**
 * RundownHQ Layout System
 * Sidebar navigation with responsive design
 */

/* App Layout Structure */
.app {
    display: flex;
    min-height: 100vh;
    background-color: #f5f7fa;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 260px; /* Space for sidebar */
    transition: margin-left 0.3s ease;
}

/* Adjust margin when sidebar is collapsed */
.sidebar.collapsed ~ .main-content {
    margin-left: 64px;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: #2c3e50;
    color: white;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1000;
    border-right: 1px solid #34495e;
}

.sidebar.collapsed {
    width: 64px;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.sidebar.collapsed .sidebar-logo:hover {
    background: rgba(255, 255, 255, 0.1);
}

.logo-image {
    height: 32px;
    width: auto;
    max-width: 200px;
    transition: all 0.3s ease;
}

.sidebar.collapsed .logo-image {
    height: 24px;
    max-width: 40px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    opacity: 0.8;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.sidebar.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar.collapsed .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Navigation Sections */
.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    color: #bdc3c7;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.section-icon {
    min-width: 20px;
    margin-right: 0.5rem;
}

.section-title {
    flex: 1;
}

.section-chevron {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.nav-section[open] .section-chevron {
    transform: rotate(180deg);
}

.sidebar.collapsed .section-title,
.sidebar.collapsed .section-chevron {
    display: none;
}

/* Navigation Items */
.section-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: #3498db;
}

.nav-link.active {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border-left-color: #3498db;
    font-weight: 600;
}

.nav-icon {
    min-width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.sidebar.collapsed .nav-link {
    padding: 0.75rem 1rem;
    justify-content: center;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid #34495e;
    background: #2c3e50;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #bdc3c7;
    font-size: 0.9rem;
}

.user-icon {
    font-size: 1.2rem;
}

.settings-btn {
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.settings-icon {
    font-size: 1rem;
}

.sidebar.collapsed .user-name {
    display: none;
}

.sidebar.collapsed .settings-btn {
    display: none;
}

/* Content Area Adjustments */
body:not(.sidebar-collapsed) .main-content {
    margin-left: 260px;
}

body.sidebar-collapsed .main-content {
    margin-left: 64px;
}

/* Header Adjustments */
.header {
    position: relative;
    z-index: 999;
}

/* Mobile Hamburger */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: white;
    margin: 2px 0;
    transition: 0.3s;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    body.mobile-menu-open .sidebar {
        transform: translateX(0);
    }
    
    body.mobile-menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    /* Animate hamburger */
    body.mobile-menu-open .mobile-menu-toggle span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    
    body.mobile-menu-open .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }
    
    body.mobile-menu-open .mobile-menu-toggle span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}

/* Hide original nav links */
.nav-links {
    display: none;
}

/* Content container adjustments */
.container {
    max-width: 95%;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* Ensure tables and content are responsive */
.table-container {
    overflow-x: auto;
}

/* Smooth scrolling for sidebar */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: #34495e #2c3e50;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #2c3e50;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #34495e;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #4a5f7a;
}

/* Focus styles for accessibility */
.nav-link:focus,
.section-header:focus,
.sidebar-toggle:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Animation for section expand/collapse */
.section-items {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Ensure proper spacing */
.sidebar.collapsed .nav-section:not([open]) .section-items {
    display: none;
}

/* Profile Settings Modal Styles */
.profile-settings-modal {
    max-width: 600px;
    width: 90%;
}

.profile-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 2rem;
}

.profile-tab {
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.profile-tab:hover {
    color: #475569;
    background: #f8fafc;
}

.profile-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.profile-photo-section {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.current-photo {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #e2e8f0;
}

.profile-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.current-photo:hover .photo-overlay {
    opacity: 1;
}

.upload-photo-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

.upload-photo-btn:hover {
    background: #1d4ed8;
}

.upload-photo-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.profile-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-form .form-group {
    margin-bottom: 1rem;
}

.profile-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.profile-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.profile-form input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.password-requirements {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.password-requirements p {
    margin: 0 0 0.5rem 0;
    font-weight: 500;
    color: #374151;
}

.password-requirements ul {
    margin: 0;
    padding-left: 1.2rem;
    color: #64748b;
}

.password-requirements li {
    margin-bottom: 0.25rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.profile-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.profile-message.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.profile-message.error {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.profile-message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Modal Overlay Styles - Global for all modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #1e293b;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.modal-body {
    padding: 2rem;
}

@media (max-width: 640px) {
    .profile-settings-modal {
        max-width: 95%;
    }
    
    .profile-form .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-actions button {
        width: 100%;
    }
}