* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.7;
    color: #333;
    background: #f5f5f5;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 0;
}

h1 {
    color: #2c3e50;
    font-size: 2.2em;
    margin-bottom: 10px;
    border-bottom: 3px solid #3498db;
    padding-bottom: 15px;
}

h2 {
    color: #2980b9;
    font-size: 1.8em;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 4px solid #3498db;
    scroll-margin-top: 15vh;
}

h3 {
    color: #34495e;
    font-size: 1.4em;
    margin-top: 30px;
    margin-bottom: 15px;
    scroll-margin-top: 15vh;
}

h4 {
    color: #555;
    font-size: 1.1em;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    scroll-margin-top: 15vh;
}

p {
    margin-bottom: 15px;
    text-align: justify;
}

.intro {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 30px;
    border-left: 4px solid #3498db;
}

.important {
    background: #fff3cd;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border-left: 4px solid #ffc107;
}

.tip {
    background: #d1ecf1;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border-left: 4px solid #17a2b8;
}

.warning {
    background: #f8d7da;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border-left: 4px solid #dc3545;
}

pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    line-height: 1.5;
}

code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: #e83e8c;
    font-size: 0.9em;
}

pre code {
    background: transparent;
    padding: 0;
    color: #f8f8f2;
}

ul, ol {
    margin-left: 30px;
    margin-bottom: 15px;
}

li {
    margin-bottom: 8px;
}

.example-box {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    margin: 20px 0;
    scroll-margin-top: 15vh;
}

.keyword {
    color: #0066cc;
    font-weight: bold;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

th {
    background: #3498db;
    color: white;
    font-weight: 600;
}

tr:nth-child(even) {
    background: #f9f9f9;
}

.section {
    margin-bottom: 50px;
    scroll-margin-top: 15vh;
}

/* ========================================
   ENHANCED MOBILE-FIRST NAVIGATION & SEARCH
   ======================================== */

/* Header sticky */
.header {
    background: linear-gradient(135deg, #4e73b8 0%, #6f9ae6 100%);
    color: white;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.3em;
    margin-bottom: 10px;
    border: none;
    padding: 0;
    color: white;
}

/* Search Bar - Mobile First */
.search-container {
    margin-top: 10px;
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: none;
    border-radius: 25px;
    font-size: 16px; /* Prevents zoom on iOS */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s;
}

#searchInput:focus {
    outline: none;
    box-shadow: 0 2px 15px rgba(0,0,0,0.2);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 1.2em;
    pointer-events: none;
}

#clearSearch {
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2em;
    display: none;
    padding: 5px;
    transition: color 0.2s;
}

#clearSearch:hover {
    color: #333;
}

/* Search Results */
.search-results {
    background: white;
    position: fixed;
    top: 140px;
    left: 10px;
    right: 10px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1001;
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 60px;
}

.search-result-item:hover,
.search-result-item:active {
    background: #f0f7ff;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    color: #2980b9;
    margin-bottom: 5px;
    font-size: 1em;
}

.search-result-preview {
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
}

.search-result-count {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 2px solid #3498db;
    font-size: 0.9em;
    color: #666;
    font-weight: 600;
}

.highlight {
    background: #fff176;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* Main Layout */
.main-layout {
    display: flex;
    position: relative;
}

/* Sidebar - Always Toggle Mode (All Devices) */
.sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 999;
    overflow-y: auto;
    padding: 20px;
    transition: left 0.3s ease;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.sidebar-header h3 {
    color: #2c3e50;
    font-size: 1.2em;
    margin: 0;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #999;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: #333;
}

/* Navigation Menu */
.nav-menu {
    list-style: none;
}

.nav-menu > li {
    margin-bottom: 5px;
}

.nav-menu a {
    display: block;
    padding: 12px 15px;
    color: #555;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s;
    font-size: 0.95em;
    min-height: 44px; /* Touch-friendly */
    display: flex;
    align-items: center;
}

.nav-menu a:hover,
.nav-menu a:active {
    background: #e3f2fd;
    color: #2980b9;
}

.nav-menu a.active {
    background: #3498db;
    color: white;
    font-weight: 600;
}

.nav-submenu {
    list-style: none;
    margin-left: 15px;
    margin-top: 5px;
    display: none;
}

.nav-submenu.show {
    display: block;
}

.nav-submenu a {
    font-size: 0.88em;
    padding: 10px 12px;
}

/* Overlay for sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* Content area */
.content {
    flex: 1;
    width: 100%;
    padding: 20px 15px;
    padding-bottom: 80px;
}

/* Floating Action Button (FAB) - Always Visible */
.fab-nav {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
    z-index: 997;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.fab-nav:hover,
.fab-nav:active {
    background: #2980b9;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.5);
}

.fab-nav.open {
    background: #e74c3c;
}

.fab-icon {
    transition: transform 0.3s;
}

.fab-nav.open .fab-icon {
    transform: rotate(90deg);
}

/* Back to top button */
#backToTop {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.3em;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: none;
    transition: all 0.3s;
    z-index: 996;
}

#backToTop:hover,
#backToTop:active {
    background: #34495e;
    transform: translateY(-3px);
}

/* Loading state for search */
.search-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}

.search-empty {
    padding: 30px 20px;
    text-align: center;
    color: #999;
}

.search-empty-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.search-empty-text {
    font-size: 1em;
    margin-bottom: 15px;
}

.search-suggestions {
    font-size: 0.9em;
    color: #666;
}

.search-suggestions strong {
    color: #3498db;
    cursor: pointer;
}

.search-suggestions strong:hover {
    text-decoration: underline;
}

/* Prevent body scroll when sidebar is open */
body.sidebar-open {
    overflow: hidden;
}

/* Tablet and Desktop (768px+) */
@media (min-width: 768px) {
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    #searchInput {
        max-width: 600px;
    }
    
    .search-results {
        position: absolute;
        top: 100%;
        left: 0;
        right: auto;
        max-width: 600px;
        max-height: 400px;
        margin-top: 10px;
    }
    
    .sidebar {
        width: 320px;
        max-width: 320px;
    }
    
    .main-layout {
        max-width: 1400px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .content {
        padding: 40px;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .fab-nav {
        bottom: 30px;
        right: 30px;
    }
    
    #backToTop {
        bottom: 100px;
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }
}

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .header h1 {
        font-size: 2em;
    }
    
    h2 {
        font-size: 1.8em;
    }
    
    h3 {
        font-size: 1.4em;
    }
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Accessibility - Focus styles */
*:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}
/* ========================================
   CODE BLOCK COPY BUTTON
   ======================================== */

/* Code block container */
pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    line-height: 1.5;
    position: relative;
}

/* Copy button */
.copy-code-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
}

pre:hover .copy-code-button {
    opacity: 1;
    pointer-events: all;
}

.copy-code-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.copy-code-button:active {
    transform: translateY(0);
}

.copy-code-button.copied {
    background: rgba(52, 211, 153, 0.3);
    border-color: rgba(52, 211, 153, 0.5);
    color: #34d399;
}

.copy-code-button .copy-icon {
    font-size: 1em;
}

/* Mobile - always show copy button */
@media (max-width: 768px) {
    .copy-code-button {
        opacity: 1;
        pointer-events: all;
        position: absolute;
        top: 8px;
        right: 8px;
    }
}

/* Ensure pre has enough top padding for button */
pre {
    padding-top: 45px;
}