/* ============================================
   QUEBRADA PAULISTA RP - REGRAS
   Design System - CSS Variables
   ============================================ */

:root {
    /* Colors - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-light: #eef2ff;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --sidebar-width: 280px;
    --toc-width: 240px;
    --content-max-width: 800px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-sidebar: #1e293b;
    --bg-hover: #334155;
    --bg-active: #475569;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-light: #1e293b;
    
    --accent-light: #312e81;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

/* ============================================
   Base Styles
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* ============================================
   Mobile Menu Toggle
   ============================================ */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-slow);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.logo-image {
    width: auto;
    height: 50px;
    object-fit: contain;
}

.logo-text {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-close {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.mobile-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mobile-close svg {
    width: 20px;
    height: 20px;
}

/* Sidebar Search */
.sidebar-search {
    padding: 16px 20px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: all var(--transition-base);
}

.search-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.nav-category {
    margin-bottom: 8px;
}

.nav-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.nav-category-header:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.nav-category-header svg {
    width: 16px;
    height: 16px;
}

.nav-category-header .chevron {
    margin-left: auto;
    transition: transform var(--transition-base);
}

.nav-category.collapsed .chevron {
    transform: rotate(-90deg);
}

.nav-category.collapsed .nav-items {
    display: none;
}

.nav-items {
    padding-left: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--accent-primary);
    background: var(--accent-light);
    font-weight: 500;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.social-links {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

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

.social-link svg {
    width: 18px;
    height: 18px;
}

.copyright {
    margin-top: 12px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    background: var(--bg-primary);
}

.content-wrapper {
    flex: 1;
    max-width: var(--content-max-width);
    padding: 40px 60px;
    margin: 0 auto;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.breadcrumb svg {
    width: 14px;
    height: 14px;
}

.breadcrumb span:last-child {
    color: var(--text-secondary);
}

/* Page Content */
.page-content {
    animation: fadeIn var(--transition-slow);
}

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

.page-header {
    margin-bottom: 40px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.page-title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--accent-light);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
}

.page-title-icon svg {
    width: 24px;
    height: 24px;
}

/* Sections */
.section {
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-base);
}

.section-header:hover {
    color: var(--accent-primary);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.section-toggle {
    margin-left: auto;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: transform var(--transition-base);
}

.section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section.collapsed .section-content {
    display: none;
}

.section-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.section-content p {
    margin-bottom: 16px;
}

.section-content p:last-child {
    margin-bottom: 0;
}

.section-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.section-content ul,
.section-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.section-content li {
    margin-bottom: 8px;
}

.section-content li:last-child {
    margin-bottom: 0;
}

.section-content ul ul,
.section-content ol ol,
.section-content ul ol,
.section-content ol ul {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: var(--font-size-sm);
}

.alert-warning {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    border-left: 4px solid var(--danger);
    color: #991b1b;
}

.alert-info {
    background: #dbeafe;
    border-left: 4px solid var(--info);
    color: #1e40af;
}

.alert-success {
    background: #d1fae5;
    border-left: 4px solid var(--success);
    color: #065f46;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

/* Tables */
.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: var(--font-size-sm);
}

.rules-table th,
.rules-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.rules-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.rules-table tr:hover td {
    background: var(--bg-hover);
}

/* Code */
.section-content code {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.9em;
    color: var(--accent-primary);
}

/* Page Navigation */
.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 60px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.page-nav-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-base);
    max-width: 50%;
}

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

.page-nav-link.next {
    align-items: flex-end;
    text-align: right;
    margin-left: auto;
}

.page-nav-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.page-nav-label svg {
    width: 14px;
    height: 14px;
}

.page-nav-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--accent-primary);
}

/* ============================================
   Table of Contents
   ============================================ */

.toc {
    position: sticky;
    top: 40px;
    width: var(--toc-width);
    max-height: calc(100vh - 80px);
    padding: 0 24px;
    overflow-y: auto;
    flex-shrink: 0;
}

.toc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.toc-header svg {
    width: 14px;
    height: 14px;
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 4px;
}

.toc-link {
    display: block;
    padding: 6px 0;
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 12px;
    margin-left: -2px;
    transition: all var(--transition-base);
}

.toc-link:hover {
    color: var(--text-primary);
}

.toc-link.active {
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-slow);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.toast-icon svg {
    width: 18px;
    height: 18px;
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

/* ============================================
   Back to Top Button
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

.back-to-top svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Search Results
   ============================================ */

.search-results {
    padding: 12px;
}

.search-result-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.search-result-category {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-dropdown.active {
    display: block;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1280px) {
    .toc {
        display: none;
    }
    
    .content-wrapper {
        padding: 32px 40px;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-wrapper {
        padding: 80px 24px 32px;
    }
    
    .page-title {
        font-size: var(--font-size-2xl);
    }
    
    .page-title-icon {
        width: 40px;
        height: 40px;
    }
    
    .page-title-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .section-title {
        font-size: var(--font-size-lg);
    }
    
    .page-nav {
        flex-direction: column;
    }
    
    .page-nav-link {
        max-width: 100%;
    }
    
    .page-nav-link.next {
        align-items: flex-start;
        text-align: left;
        margin-left: 0;
    }
    
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
    
    .back-to-top {
        bottom: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    .content-wrapper {
        padding: 72px 16px 24px;
    }
    
    .breadcrumb {
        display: none;
    }
    
    .page-title {
        font-size: var(--font-size-xl);
        gap: 12px;
    }
    
    .page-title-icon {
        width: 36px;
        height: 36px;
    }
    
    .page-title-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .section {
        margin-bottom: 32px;
    }
    
    .section-header {
        gap: 8px;
    }
    
    .section-title {
        font-size: var(--font-size-base);
    }
    
    .alert {
        padding: 12px 16px;
    }
    
    .rules-table th,
    .rules-table td {
        padding: 10px 12px;
        font-size: var(--font-size-xs);
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .sidebar,
    .toc,
    .mobile-menu-toggle,
    .back-to-top,
    .toast-container,
    .page-nav {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-wrapper {
        max-width: 100%;
        padding: 0;
    }
}
