/**
 * Ring2All Documentation Portal
 * Main Styles - Premium Modern Design
 */

/* ============================================
   CSS Variables (Theme)
   ============================================ */
:root {
    /* Colors - Dark Theme (Default) - Softer Blue-Gray */
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: rgba(59, 130, 246, 0.12);
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --accent-light: rgba(6, 182, 212, 0.1);

    /* Gradient accents */
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --gradient-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.05) 100%);

    /* Softer backgrounds - blue-gray instead of pure black */
    --bg-primary: #0f1729;
    --bg-secondary: #182234;
    --bg-tertiary: #243447;
    --bg-elevated: #1e2d42;
    --bg-card: linear-gradient(180deg, rgba(36, 52, 71, 0.6) 0%, rgba(24, 34, 52, 0.6) 100%);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #60a5fa;

    --border: rgba(148, 163, 184, 0.12);
    --border-hover: rgba(148, 163, 184, 0.2);
    --border-focus: rgba(59, 130, 246, 0.5);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);

    /* Glassmorphism - Enhanced */
    --glass-bg: rgba(24, 34, 52, 0.9);
    --glass-border: rgba(148, 163, 184, 0.12);
    --glass-blur: blur(20px);
    --glass-saturate: saturate(180%);

    /* Dimensions */
    --header-height: 68px;
    --sidebar-width: 280px;
    --content-max-width: 100%;
    --toc-width: 220px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #fafbfc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-card: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-accent: #2563eb;

    --border: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(15, 23, 42, 0.12);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.1);

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(15, 23, 42, 0.06);
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 80% 80% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
        radial-gradient(ellipse 60% 60% at 80% 50%, rgba(139, 92, 246, 0.08), transparent);
    pointer-events: none;
    z-index: -1;
}

[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 80% 80% at 50% -20%, rgba(59, 130, 246, 0.08), transparent),
        radial-gradient(ellipse 60% 60% at 80% 50%, rgba(139, 92, 246, 0.05), transparent);
}

/* ============================================
   Layout
   ============================================ */
.main-container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

.content {
    flex: 1;
    display: flex;
    gap: 40px;
    padding: 40px 56px;
    margin-left: var(--sidebar-width);
    max-width: calc(100% - var(--sidebar-width));
}

.content-wrapper {
    flex: 1;
    min-width: 0;
}

/* ============================================
   Header - Premium Glassmorphism
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur) var(--glass-saturate);
    -webkit-backdrop-filter: var(--glass-blur) var(--glass-saturate);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.3;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sidebar-toggle {
    display: none;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-img {
    height: 34px;
    width: auto;
}

.logo-badge {
    padding: 4px 10px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
}

/* Logo visibility based on theme */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

[data-theme="light"] .logo-light {
    display: none;
}

[data-theme="light"] .logo-dark {
    display: block;
}

/* ============================================
   Search - Static Inline Input
   ============================================ */
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 560px;
    margin: 0 32px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.search-wrapper:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-glow);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    transition: var(--transition-fast);
}

.search-wrapper:focus-within .search-icon {
    color: var(--primary);
}

.search-input {
    flex: 1;
    padding: 12px 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-kbd {
    padding: 5px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 420px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition-fast);
    z-index: 200;
}

.search-wrapper.has-results .search-results-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-results-inner {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.search-result {
    display: block;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.search-result:hover,
.search-result.selected {
    background: var(--primary-light);
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-title i {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.search-result-path {
    font-size: 12px;
    color: var(--text-muted);
}

.search-no-results {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-muted);
}

.search-no-results p {
    margin-bottom: 4px;
}

.search-no-results span {
    font-size: 13px;
    opacity: 0.7;
}

.search-loading {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.search-result-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.search-result-snippet mark,
.search-result-title mark {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
    padding: 1px 2px;
    border-radius: 2px;
}

/* ============================================
   Header Right
   ============================================ */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.header-icon-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.theme-icon-light,
.theme-icon-dark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: var(--transition-normal);
}

[data-theme="dark"] .theme-icon-light {
    opacity: 1;
}

[data-theme="dark"] .theme-icon-dark {
    opacity: 0;
}

[data-theme="light"] .theme-icon-light {
    opacity: 0;
}

[data-theme="light"] .theme-icon-dark {
    opacity: 1;
}

.header-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: var(--transition-fast);
}

.header-link:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.header-link i {
    width: 14px;
    height: 14px;
}

/* ============================================
   Breadcrumbs
   ============================================ */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    font-size: 14px;
    color: var(--text-muted);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumbs a:hover {
    color: var(--primary);
}

.breadcrumbs .separator {
    color: var(--text-muted);
    opacity: 0.5;
}

.breadcrumbs .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================
   Table of Contents
   ============================================ */
.toc {
    position: sticky;
    top: calc(var(--header-height) + 40px);
    width: var(--toc-width);
    min-width: var(--toc-width);
    max-height: calc(100vh - var(--header-height) - 80px);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.toc h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.toc nav a {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    border-left: 2px solid transparent;
    margin-left: -2px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: var(--transition-fast);
}

.toc nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.toc nav a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-light);
    font-weight: 500;
}

/* ============================================
   Page Navigation
   ============================================ */
.page-nav {
    display: flex;
    gap: 24px;
    margin-top: 56px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.page-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: var(--transition-fast);
}

.page-nav-link:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-nav-link.prev {
    align-items: flex-start;
}

.page-nav-link.next {
    align-items: flex-end;
}

.page-nav-link .label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.page-nav-link .title {
    font-weight: 600;
    color: var(--primary);
}

.page-nav-link.empty {
    visibility: hidden;
}

/* ============================================
   404 Error
   ============================================ */
.error-404 {
    text-align: center;
    padding: 100px 20px;
}

.error-404 h1 {
    font-size: 140px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 20px;
}

.error-404 p {
    font-size: 18px;
    color: var(--text-muted);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 260px;
    }

    .content {
        padding: 28px;
    }

    .header-center {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        transition: left var(--transition-normal);
    }

    .sidebar.open {
        left: 0;
    }

    .content {
        margin-left: 0;
        max-width: 100%;
    }

    .header-center {
        display: none;
    }

    .header-link span {
        display: none;
    }

    .page-nav {
        flex-direction: column;
    }
}