/* ================================================================
   ScriptaDocX — Global Styles
   
   ================================================================ */

/* ---- Theme Variables ---- */
:root,
[data-theme="dark"] {
    --text-tool-color: #eab308;
    --text-tool-bg: rgba(234, 179, 8, 0.1);
    --bg-base: #09090b;
    --bg-surface: #111114;
    --bg-elevated: #18181c;
    --bg-hover: #1f1f25;
    --bg-active: #27272e;
    --bg-overlay: rgba(0, 0, 0, 0.5);

    --border-subtle: #1e1e26;
    --border-default: #2a2a34;
    --border-strong: #383844;

    --text-primary: #ececef;
    --text-secondary: #9494a0;
    --text-muted: #5c5c6a;

    --accent: #6c63ff;
    --accent-hover: #7b73ff;
    --accent-muted: rgba(108, 99, 255, 0.12);
    --accent-glow: rgba(108, 99, 255, 0.2);

    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-muted: rgba(239, 68, 68, 0.12);

    --pdf-color: #ef4444;
    --pdf-bg: rgba(239, 68, 68, 0.1);
    --img-color: #22c55e;
    --img-bg: rgba(34, 197, 94, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);

    --header-height: 56px;
    --max-width: 920px;
}

[data-theme="light"] {
    --text-tool-color: #eab308;
    --text-tool-bg: rgba(234, 179, 8, 0.1);
    --bg-base: #f5f6f8;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f1f4;
    --bg-active: #e4e5ea;
    --bg-overlay: rgba(0, 0, 0, 0.2);

    --border-subtle: #eaebef;
    --border-default: #d6d7dd;
    --border-strong: #b8b9c2;

    --text-primary: #111118;
    --text-secondary: #55555f;
    --text-muted: #8c8c96;

    --accent: #5046e5;
    --accent-hover: #4338ca;
    --accent-muted: rgba(80, 70, 229, 0.07);
    --accent-glow: rgba(80, 70, 229, 0.12);

    --success: #16a34a;
    --success-muted: rgba(22, 163, 74, 0.07);
    --danger: #dc2626;
    --danger-muted: rgba(220, 38, 38, 0.07);

    --pdf-color: #dc2626;
    --pdf-bg: rgba(220, 38, 38, 0.06);
    --img-color: #16a34a;
    --img-bg: rgba(22, 163, 74, 0.06);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-base);
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ================================================================
   HEADER
   ================================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.logo-mark { display: flex; align-items: center; }

.logo-text-group { display: flex; align-items: baseline; gap: 6px; }

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-version {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}

.icon-sun, .icon-moon { position: absolute; }
[data-theme="dark"] .icon-sun  { opacity: 1; }
[data-theme="dark"] .icon-moon { opacity: 0; }
[data-theme="light"] .icon-sun  { opacity: 0; }
[data-theme="light"] .icon-moon { opacity: 1; }

.header-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
}

.header-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-muted);
}

/* ================================================================
   HEADER NAV — Click-based dropdowns
   ================================================================ */
.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-dropdown {
    position: relative;
}

.nav-trigger {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
}

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

.nav-trigger svg {
    transition: transform 150ms ease;
}

/* Active state when open */
.nav-dropdown.open .nav-trigger {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-dropdown.open .nav-trigger svg {
    transform: rotate(180deg);
}

/* Menu — controlled ONLY by .open class via JS */
.nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 300;
}

/* ONLY open via JS class — no :hover rule */
.nav-dropdown.open .nav-menu {
    display: block;
}

.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

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

.nav-menu-item__icon {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-menu-item__icon svg { width: 13px; height: 13px; }
.nav-menu-item__icon--pdf { background: var(--pdf-bg); color: var(--pdf-color); }
.nav-menu-item__icon--img { background: var(--img-bg); color: var(--img-color); }
.nav-menu-item__text { font-weight: 500; }

/* ================================================================
   MOBILE NAV
   ================================================================ */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 20px;
    margin-left: auto;
}

.mobile-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: transform 200ms ease, opacity 150ms ease;
}


.mobile-menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(3px, 3px); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(3px, -3px); }

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    background: var(--bg-overlay);
}

.mobile-nav-overlay.active {
    display: block;
}


.mobile-nav-panel {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 14px 18px;
    max-height: 70vh;
    overflow-y: auto;
}

.mobile-nav-section { margin-bottom: 14px; }
.mobile-nav-section:last-child { margin-bottom: 0; }

.mobile-nav-label {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 4px;
}

.mobile-nav-item {
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

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

/* ================================================================
   MAIN + VIEWS
   ================================================================ */
.main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

.view {
    display: none;
    padding: 24px 0 40px;
}

.view.active { display: block; }

/* ================================================================
   TOOL VIEW
   ================================================================ */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: 1px solid var(--border-default);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 20px;
}

.back-button:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-muted);
}

.tool-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.tool-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-muted);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.tool-hero-info h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tool-hero-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ================================================================
   TOOLS GRID
   ================================================================ */
.tools-section {
    padding-top: 16px;
    padding-bottom: 32px;
}

.tools-category { margin-bottom: 28px; }

.category-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 2px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

/* ================================================================
   LANDING
   ================================================================ */
.landing {
    position: relative;
    min-height: calc(100vh - var(--header-height) - 40px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 36px 0;
}

.landing-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.landing-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 580px;
    padding: 0 20px;
}

.landing-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: var(--accent-muted);
    padding: 4px 13px;
    border-radius: 20px;
    border: 1px solid rgba(108, 99, 255, 0.12);
    margin-bottom: 18px;
}

.landing-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.08;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.landing-title-accent {
    background: linear-gradient(135deg, var(--accent), #f7436d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 24px;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

.landing-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.landing-cta {
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.landing-cta--filled {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.landing-cta--filled:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 18px var(--accent-glow);
}

.landing-cta--outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}

.landing-cta--outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}

.landing-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 22px;
}

.landing-stat { text-align: center; }

.landing-stat__number {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.landing-stat__label {
    display: block;
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.landing-stat__divider {
    width: 1px;
    height: 28px;
    background: var(--border-default);
}

.landing-credit {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.landing-credit strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.scroll-indicator {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    z-index: 1;
}

.scroll-indicator span {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.scroll-indicator:hover span,
.scroll-indicator:hover .scroll-mouse {
    color: var(--accent);
    border-color: var(--accent);
}

.scroll-mouse {
    width: 20px;
    height: 32px;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    padding-top: 6px;
}

.scroll-wheel {
    width: 3px;
    height: 6px;
    border-radius: 2px;
    background: var(--text-muted);
}

.scroll-indicator:hover .scroll-wheel {
    background: var(--accent);
}

/* ================================================================
   FOOTER
   ================================================================ */
.footer {
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
    width: 100%;
    background: var(--bg-surface);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 32px 20px 20px;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
    padding-bottom: 24px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
}

.footer-brand span {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.footer-tagline {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer-right {
    flex-shrink: 0;
    text-align: right;
}

.footer-heading {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.footer-socials {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.footer-social-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 6px;
    text-decoration: none;
}

.footer-social-link:hover {
    color: var(--accent);
    background: var(--accent-muted);
}

.footer-social-link svg {
    flex-shrink: 0;
    opacity: 0.65;
}

.footer-social-link:hover svg { opacity: 1; }

.footer-bottom {
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.footer-bottom p {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.footer-bottom strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .header {
        padding: 0 12px;
    }

    .header-left {
        gap: 6px;
    }

    .logo-text {
        font-size: 0.95rem;
    }

    .logo-version {
        display: none;
    }

    .header-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .header-link {
        display: none;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
        margin-right: 4px;
    }

    .mobile-menu-toggle {
        display: flex;
        flex-shrink: 0;
    }

    .header-nav {
        display: none;
    }

    .main {
        padding: 0 14px;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .landing {
        min-height: calc(100vh - var(--header-height) - 30px);
        min-height: calc(100dvh - var(--header-height) - 30px);
        padding: 24px 0;
        width: 100%;
    }

    .landing-title {
        font-size: clamp(1.5rem, 5vw, 2.2rem);
    }

    .landing-actions {
        flex-direction: column;
        align-items: center;
    }

    .landing-cta {
        width: 100%;
        max-width: 240px;
        justify-content: center;
    }

    .landing-stats {
        gap: 14px;
    }

    .landing-stat__number {
        font-size: 1.2rem;
    }

    .tool-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .footer-top {
        flex-direction: column;
        gap: 20px;
    }

    .footer-right {
        text-align: left;
    }

    .footer-socials {
        align-items: flex-start;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 360px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 0 10px;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    .theme-toggle {
        width: 30px;
        height: 30px;
    }

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

    .mobile-menu-toggle span {
        width: 16px;
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .mobile-nav-overlay {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .tools-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
    .mobile-menu-toggle { display: none !important; }
    .mobile-nav-overlay { display: none !important; }
}
