/* ===========================
   CSS Variables & Theme
   =========================== */

:root {

    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a1a;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --accent-primary: #0056b3;
    --accent-hover: #003d82;
    --accent-button: #0056b3;
    --success: #28a745;
    --warning: #e67e00;
    --danger: #dc3545;

    /* UI Elements */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-info: 0 8px 8px 0;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2e2e2e;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-muted: #868e96;
    --border-color: #3a3a3a;
    --accent-primary: #4d9fff;
    --accent-hover: #6bb0ff;
    --accent-button: #1e6cd2;
    --success: #51cf66;
    --warning: #ffd43b;
    --danger: #ff6b6b;

    /* Adjusted Shadows for Dark Mode */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* ===========================
   Reset & Base Styles
   =========================== */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ===========================
   Typography
   =========================== */

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

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
    margin-top: 2.5rem;
}

h3 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
}

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

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

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
}

.code-inline {
    display: block;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

pre {
    margin: 1.5rem 0;
}

pre code {
    display: block;
    padding: 1.5rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow-x: auto;
    line-height: 1.6;
    border: 1px solid var(--border-color);
}

/* ===========================
   Layout
   =========================== */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===========================
   Header
   =========================== */

.header {
    position: sticky;
    top: 0;
    width: 100%;
    background: linear-gradient(170deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* margin-bottom: 2rem; */
    gap: 2rem;
}

.brand {
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
    transition: color var(--transition-fast);
}

.brand-link:hover {
    color: var(--accent-primary);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: block;
}

.brand-name {
    display: block;
}

.main-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-list {
    display: flex;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--accent-primary);
    text-decoration: none;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.lang-link {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    min-width: 52px;
}

.lang-link:hover {
    background-color: var(--bg-primary);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.theme-toggle {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    min-width: 52px;
}

.theme-toggle:hover {
    background-color: var(--bg-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    /* display: block; */
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

/* ===========================
   HERO
   =========================== */

.hero {
    padding: 4rem 0 3rem;
}

.header-content {
    text-align: center;
}

.header-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

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

.main {
    padding-bottom: 4rem;
}

.tool-section {
    margin-bottom: 4rem;
}

.content-section {
    margin-bottom: 3rem;
}

/* ===========================
   Tool Box
   =========================== */

.tool-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-top: 1.5rem;
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tool-label {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.tool-actions {
    display: flex;
    gap: 0.5rem;
}

.code-input,
.code-output {
    width: 100%;
    padding: 1.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    border: none;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    transition: background-color var(--transition-base);
}

.code-input:focus,
.code-output:focus {
    outline: none;
    background-color: var(--bg-primary);
}

.code-input::placeholder,
.code-output::placeholder {
    color: var(--text-muted);
}

.code-output {
    background-color: var(--bg-tertiary);
}

.tool-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.tool-divider svg {
    color: var(--accent-primary);
    opacity: 0.6;
}

/* ===========================
   Buttons
   =========================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.btn.copied {
    background-color: var(--success) !important;
    color: white !important;
}

/* ===========================
   Info Boxes
   =========================== */

.info-box {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-info);
    margin: 1.5rem 0;
}

.info-box.warning {
    border-left-color: var(--warning);
}

.info-box.fun-fact {
    border-left-color: var(--success);
}

.info-icon {
    background-image: url(info.svg);
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.danger-icon {
    background-image: url(danger.svg);
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 28px;
    height: 24px;
}

/* .info-icon img,
.danger-icon img {
    width: 100%;
    height: 100%;
    display: block;
} */

.info-box img {
    width: 100%;
    height: 100%;
    display: block;
}

.info-content {
    flex: 1;
}

.info-content strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-content p {
    margin-bottom: 0;
}

.info-content em {
    color: var(--accent-primary);
    font-style: normal;
    font-weight: 500;
}

/* ===========================
   Preview Grid
   =========================== */

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.preview-box {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.preview-box h3 {
    font-size: 1rem;
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.preview-text {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    padding: 1rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    word-break: break-all;
    margin-bottom: 0;
}

/* ===========================
   Use Cases
   =========================== */

.use-case {
    margin-bottom: 2rem;
}

.use-case h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.use-case p {
    margin-bottom: 0.5rem;
}

/* ===========================
   Code Examples
   =========================== */

.code-example {
    margin: 1.5rem 0;
}

/* ===========================
   Utilities
   =========================== */

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===========================
   Footer
   =========================== */

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

.footer p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.footer .nav-list {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.footer-note {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

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

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .header {
        padding: 1rem 0 1.5rem;
    }

    .header-top {
        flex-wrap: wrap;
        margin-bottom: 1.5rem;
        gap: 1rem;
    }

    .brand {
        order: 1;
    }

    .header-controls {
        order: 2;
        gap: 0.5rem;
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .nav-list {
        gap: 1.5rem;
    }

    .nav-link {
        font-size: 0.9rem;
    }

    .header-title {
        font-size: 1.75rem;
    }

    .header-subtitle {
        font-size: 1rem;
    }

    .lang-link,
    .theme-toggle {
        padding: 0.5rem 0.7rem;
        min-width: 44px;
    }

    .tool-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .tool-actions {
        width: 100%;
    }

    .btn {
        flex: 1;
        justify-content: center;
    }

    .preview-grid {
        grid-template-columns: 1fr;
    }

    h2 {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    .nav-list {
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .brand-link {
        font-size: 1rem;
    }

    .code-input,
    .code-output {
        font-size: 0.85rem;
        padding: 1rem;
    }

    pre code {
        font-size: 0.8rem;
        padding: 1rem;
    }
}

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

@media print {

    .theme-toggle,
    .tool-actions,
    .footer {
        display: none;
    }

    body {
        background-color: white;
        color: black;
    }
}