/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* CSS Variables for Theming */
:root {
    /* Light Theme Colors */
    --bg-primary: #fafbfc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f4;
    --text-primary: #1a202c;
    --text-secondary: #303030;
    --text-muted: #4a5568;
    --accent-primary: #3182ce;
    --accent-secondary: #2b6cb0;
    --accent-tertiary: #1a365d;
    --border-color: #e2e8f0;
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.12);
    --shadow-heavy: rgba(0, 0, 0, 0.16);
    
    /* Clan-specific colors */
    --clan-primary: #6b4226;
    --clan-secondary: #68615d;
    --clan-accent: #b8860b;
    --region-primary: #92c9b2;
    --region-secondary: #14302b;
}

/* Dark Theme Colors */
body.dark-theme {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e0;
    --text-muted: #a0aec0;
    --accent-primary: #4299e1;
    --accent-secondary: #3182ce;
    --accent-tertiary: #2b6cb0;
    --border-color: #4a5568;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.5);
    
    /* Clan-specific colors for dark theme */
    --clan-primary: #b8956a;
    --clan-secondary: #8b7355;
    --clan-accent: #f4d03f;
    --region-primary: #4a7c59;
    --region-secondary: #3e6b4a;
}

/* Base Typography */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--accent-secondary);
}

/* Container */
.container {
    max-width: 80%;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow-light);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--clan-primary);
    text-shadow: 1px 1px 2px var(--shadow-light);
    margin: 0;
}

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

.theme-toggle,
.mobile-menu-toggle {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover,
.mobile-menu-toggle:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mobile-menu-toggle {
    display: none;
}

/* Main Container */
.main-container {
    display: block; /* Change from flex to block for fixed sidebar */
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    position: fixed;
    top: 70px; /* Below header */
    left: 0;
    height: calc(100vh - 70px);
    transition: width 0.3s ease;
    z-index: 95;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--clan-primary), var(--region-primary));
    color: white;
    position: relative;
    z-index: 100;
    flex-shrink: 0; /* Prevent header from shrinking */
    overflow: hidden; /* Prevent header content from overflowing */
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    margin: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 60px); /* Leave space for toggle button */
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    pointer-events: none;
}

.sidebar-toggle {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    position: relative;
    z-index: 1000;
    flex-shrink: 0; /* Prevent button from shrinking */
    pointer-events: auto;
    overflow: visible;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.nav-header {
    padding: 1rem 1.5rem 0.5rem;
    margin-bottom: 0.5rem;
    display: none; /* Hide the old nav header */
}

.nav-header h3 {
    color: var(--clan-primary);
    font-size: 1.1rem;
    margin-bottom: 0;
}

.nav-menu {
    list-style: none;
    padding: 0.5rem 0;
    overflow-x: hidden; /* Prevent horizontal overflow */
    width: 100%;
}

.nav-menu li {
    margin-bottom: 0;
}

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

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    text-decoration: none;
    position: relative;
    font-size: 0.9rem;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
    z-index: 1;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
    text-align: center;
    transition: margin 0.3s ease;
    flex-shrink: 0;
}

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

.nav-link .nav-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0; /* Allow text to shrink */
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    pointer-events: none;
}

.nav-link:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.nav-link.active {
    background-color: var(--accent-primary);
    color: white;
    border-left-color: var(--accent-secondary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(49, 130, 206, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(49, 130, 206, 0);
    }
}

.nav-link.active i {
    color: white;
}

.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease,
                padding 0.3s ease;
    opacity: 0;
    padding: 0;
}

.nav-section.expanded .nav-submenu {
    max-height: 500px;
    opacity: 1;
    padding: 0.25rem 0;
}

.nav-submenu .nav-link {
    padding: 0.5rem 1rem 0.5rem 3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-left: none;
}

/* Mobile submenu styles */
.nav-submenu {
    background-color: rgba(0, 0, 0, 0.05); /* Slight background to distinguish from main menu */
}

.nav-submenu .nav-link {
    padding-left: 2.5rem; /* Reduce indentation on mobile for better space usage */
    font-size: 0.9rem; /* Slightly larger font for better touch targets */
    min-height: 44px; /* Ensure adequate touch target size */
    display: flex;
    align-items: center;
}

.nav-section.expanded .nav-submenu {
    border-left: 2px solid var(--accent-primary); /* Visual indicator of expanded state */
}

.sidebar.collapsed .nav-submenu .nav-link {
    padding-left: 1rem;
}

.nav-submenu .nav-link:hover {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.nav-submenu .nav-link.active {
    color: var(--accent-primary);
    background-color: rgba(var(--accent-primary-rgb, 49, 130, 206), 0.1);
    border-left: 3px solid var(--accent-primary);
}

.nav-section > .nav-link::after {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    margin-left: auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.sidebar.collapsed .nav-section > .nav-link::after {
    opacity: 0;
}

.nav-section.expanded > .nav-link::after {
    transform: rotate(90deg);
}

/* Main Content */
.main-content {
    padding: 2rem;
    background-color: var(--bg-primary);
    min-height: calc(100vh - 70px); /* Full height minus header */
    transition: margin-left 0.3s ease;
}

/* Desktop: Account for sidebar width */
@media (min-width: 969px) {
    .main-content {
        margin-left: 280px; /* Account for full sidebar width - will be overridden by JS */
    }
    
    /* Note: Collapsed state margin is handled by JavaScript since sidebar is fixed positioned */
}

/* Content Sections */
.content-section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--clan-primary), var(--region-primary));
    color: white;
    border-radius: 12px;
    margin-bottom: 3rem;
    box-shadow: 0 4px 20px var(--shadow-medium);
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 0;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-light);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: 1.5rem;
}

.card-content h3 {
    color: var(--clan-primary);
    margin-bottom: 0.5rem;
}

.card-content p {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--clan-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--clan-secondary);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--region-primary);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--region-secondary);
    transform: translateY(-2px);
}

.btn-accent {
    background-color: var(--clan-accent);
    color: var(--text-primary);
}

.btn-accent:hover {
    background-color: var(--clan-accent);
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Section Content */
.section-content {
    max-width: 800px;
}

.image-placeholder {
    width: 100%;
    margin-bottom: 2rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-light);
}

.image-placeholder img {
    width: 100%;
    height: auto;
    display: block;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.info-card {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.info-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.info-card h4 {
    color: var(--clan-primary);
    margin-bottom: 0.5rem;
}

/* Feature List */
.feature-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.feature-item:hover {
    background-color: var(--bg-tertiary);
}

.feature-item i {
    color: var(--clan-primary);
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.feature-item h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.feature-item p {
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Getting Started Grid */
.getting-started-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.step-card {
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.step-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--clan-primary), var(--region-primary));
}

.step-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.step-number {
    display: inline-block;
    width: 50px;
    height: 50px;
    background-color: var(--clan-primary);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.step-card h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.step-card p {
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer p {
    color: var(--text-muted);
    margin-bottom: 0;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--accent-primary);
}

/* Tooltip for collapsed sidebar */
.nav-link .tooltip {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 200px;
    word-wrap: break-word;
}

.sidebar.collapsed .nav-link:hover .tooltip {
    opacity: 1;
}

.sidebar:not(.collapsed) .tooltip {
    display: none;
}

/* Resizer for desktop */
.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -2px; /* Move it slightly outside the sidebar */
    width: 4px;
    height: 100%;
    background-color: transparent;
    cursor: col-resize;
    transition: background-color 0.3s ease;
    z-index: 50; /* Lower than the toggle button */
    pointer-events: auto;
}

.sidebar-resizer:hover {
    background-color: var(--accent-primary);
    width: 6px;
    right: -3px;
}

/* Hide resizer when sidebar is collapsed to prevent interference */
.sidebar.collapsed .sidebar-resizer {
    display: none;
}

@media (max-width: 968px) {
    .sidebar {
        position: fixed;
        top: 0; /* Start at top to connect with header */
        left: -280px; /* Hide off-screen by default */
        width: 280px;
        height: 100vh; /* Full height */
        z-index: 1000;
        background-color: var(--bg-secondary);
        transition: left 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .sidebar.active {
        left: 0; /* Slide in when active */
    }
    
    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0; /* Start at top to match sidebar */
        left: 0;
        width: 100%;
        height: 100vh; /* Full height to match sidebar */
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Ensure sidebar doesn't interfere with desktop collapsed state on mobile */
    .sidebar.collapsed {
        width: 280px; /* Override collapsed width on mobile */
        left: -280px; /* Keep off-screen */
    }
    
    .sidebar.collapsed.active {
        left: 0; /* Still slide in when active, even if collapsed */
    }
    
    .sidebar-resizer {
        display: none;
    }
    
    /* Show mobile menu toggle on mobile */
    .mobile-menu-toggle {
        display: flex !important; /* Override the default display: none */
    }
    
    /* Hide sidebar toggle button on mobile since we have hamburger menu */
    .sidebar-toggle {
        display: none !important;
    }
    
    /* Reset main content margin on mobile */
    .main-content {
        margin-left: 0 !important; /* Override desktop margins */
    }
        
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .getting-started-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .footer .container {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    /* Mobile sidebar improvements */
    .sidebar-header {
        position: sticky;
        top: 0;
        z-index: 1001; /* Ensure header stays above content when scrolling */
        box-shadow: 0 2px 4px var(--shadow-light);
    }
    
    /* Better mobile sidebar styling */
    .sidebar {
        border-right: none; /* Remove border on mobile since it's an overlay */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3); /* Add shadow for depth */
    }
}



@media (max-width: 480px) {
    .header-content {
        padding: 0.5rem 0;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    /* Ensure mobile menu toggle is visible on small screens too */
    .mobile-menu-toggle {
        display: flex !important;
        width: 36px;
        height: 36px; /* Slightly smaller for very small screens */
    }
    
    /* Hide sidebar toggle button on mobile since we have hamburger menu */
    .sidebar-toggle {
        display: none !important;
    }
    
    .hero-section {
        padding: 2rem 1rem;
    }
    
    .hero-title {
        font-size: 1.8rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .step-card {
        padding: 1.5rem;
    }
    
    .feature-item {
        flex-direction: column;
        text-align: center;
    }
    
    .feature-item i {
        margin-bottom: 0.5rem;
    }
    
    /* Mobile sidebar improvements for small screens */
    .sidebar-header {
        position: sticky;
        top: 0;
        z-index: 1001; /* Ensure header stays above content when scrolling */
        box-shadow: 0 2px 4px var(--shadow-light);
    }
    
    /* Better mobile sidebar styling for small screens */
    .sidebar {
        border-right: none; /* Remove border on mobile since it's an overlay */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3); /* Add shadow for depth */
    }
}