/* Basic page layout and header */
:root {
    --bg-color: #f7f9fb;
    --text-color: #0b1220;
    --text-muted: #666;
    --card-bg: #fff;
    --border-color: #e6eef6;
    --header-bg: #27619B;
    --header-text: #fff;
    --primary-btn-bg: #2563eb;
    --primary-btn-text: #fff;
    --link-color: #0284c7;
    --input-bg: #fff;
    --input-border: #d2e0ee;
    --kv-header-bg: #f5f8fb;
    --kv-border: #eef6ff;
}

body.dark-mode {
    --bg-color: #161f2c;
    --text-color: #ffffff;
    --text-muted: #a0aec0;
    --card-bg: #1e293b;
    --border-color: #2d3748;
    --header-bg: #0f172a;
    --header-text: #e2e8f0;
    --primary-btn-bg: #a87ffb;
    --primary-btn-text: #fff;
    --link-color: #63b3ed;
    --input-bg: #2d3748;
    --input-border: #4a5568;
    --kv-header-bg: #2d3748;
    --kv-border: #4a5568;
}

body.hacker-mode {
    --bg-color: #0a0f0a;
    --text-color: #00ff00;
    --text-muted: #00cc00;
    --card-bg: #0d140d;
    --border-color: #1a3d1a;
    --header-bg: #001400;
    --header-text: #00ff00;
    --primary-btn-bg: #00aa00;
    --primary-btn-text: #000;
    --link-color: #00ff88;
    --input-bg: #0d140d;
    --input-border: #1a3d1a;
    --kv-header-bg: #0d140d;
    --kv-border: #1a3d1a;
}

body.developer-mode {
    --bg-color: #0d1117;
    --text-color: #e6edf3;
    --text-muted: #8b949e;
    --card-bg: #161b22;
    --border-color: #30363d;
    --header-bg: #172f45;
    --header-text: #e6edf3;
    --primary-btn-bg: #238636;
    --primary-btn-text: #fff;
    --link-color: #58a6ff;
    --input-bg: #0d1117;
    --input-border: #30363d;
    --kv-header-bg: #161b22;
    --kv-border: #30363d;
}

/* Page layout: make footer stick to bottom */
html,
body {
    height: 100%
}

*,
*::before,
*::after {
    box-sizing: border-box
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Figtree, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-main {
    color: var(--text-color) !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 18px
}

.container-wide {
    max-width: 98%;
    margin: 0 auto;
    padding: 0 1%
}

/* Ensure main grows so footer sticks to bottom */
main {
    flex: 1
}

/* Header */
.site-header {
    background: var(--header-bg);
    padding: 22px 0;
    color: var(--header-text);
    position: relative;
    transition: background-color 0.3s ease;
}

.site-header .container {
    max-width: 100%;
    padding: 0 18px;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: none;
    gap: 20px;
    box-sizing: border-box;
}

.header-left {
    flex-shrink: 1;
    margin-right: auto;
    min-width: 0;
}

.header-right {
    display: none;
}

.site-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    font-size: 24px;
    margin: 0;
    flex-shrink: 1;
}

.site-logo {
    background: #0E4453;
    color: #27EFE6;
    padding: 10px 14px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 24px;
}

/* Navigation */
/* Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Increased gap for better spacing */
    margin-left: auto;
}

.header-nav a,
.dropbtn {
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    /* Larger padding */
    border-radius: 6px;
    font-weight: 600;
    /* Bolder font */
    font-size: 17px;
    /* Larger font size */
    transition: background-color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.header-nav a:hover,
.dropdown:hover .dropbtn {
    background: rgba(255, 255, 255, 0.1);
}

.header-nav a.active {
    background: rgba(255, 255, 255, 0.2);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    position: absolute;
    background-color: #fff;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    z-index: 1002;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    overflow: visible;
    padding: 8px 0;
    white-space: nowrap;
    /* Elegant animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

/* Invisible bridge to maintain hover when moving from button to dropdown */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 15px;
    font-weight: 500;
    border-radius: 0;
    background-color: #fff;
}

.dropdown-content a:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-content a:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-content a:hover {
    background-color: #f1f5f9;
    color: var(--link-color);
}

.dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

body.dark-mode .dropdown-content {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.dark-mode .dropdown-content a {
    color: var(--text-color);
}

body.dark-mode .dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Hamburger Menu */
.hamburger-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #fff;
    margin: 5px 0;
    transition: 0.3s;
}

/* Mobile Menu Styles */
@media (max-width: 900px) {
    .header-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 250px;
        height: 100vh;
        background: #27619B;
        flex-direction: column;
        align-items: flex-start;
        padding: 80px 20px 20px;
        transition: 0.3s ease-in-out;
        z-index: 1000;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
        margin-left: 0;
    }

    .header-nav.active {
        right: 0;
    }

    .header-nav a {
        width: 100%;
        padding: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .hamburger-menu {
        display: block;
        margin-left: auto;
    }

    /* Hamburger Animation */
    .hamburger-menu.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .hamburger-menu.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger-menu.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}

/* Dark Mode Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--header-text);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

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

.theme-dropdown .dropdown-content {
    min-width: 120px;
}

.theme-menu a {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

/* Hacker mode specific styles */
body.hacker-mode .site-header {
    border-bottom: 1px solid #00ff00;
}

body.hacker-mode .site-logo {
    background: #001400;
    color: #00ff00;
    border: 1px solid #00ff00;
}

body.hacker-mode .header-nav a,
body.hacker-mode .dropbtn {
    color: #00ff00;
}

body.hacker-mode .header-nav a:hover,
body.hacker-mode .dropdown:hover .dropbtn {
    background: rgba(0, 255, 0, 0.1);
}

body.hacker-mode .dropdown-content {
    background-color: #0d140d;
    border: 1px solid #1a3d1a;
}

body.hacker-mode .dropdown-content a {
    color: #00ff00;
    background-color: #0d140d;
}

body.hacker-mode .dropdown-content a:hover {
    background-color: rgba(0, 255, 0, 0.1);
}

/* Developer mode dropdown styles */
body.developer-mode .dropdown-content {
    background-color: #161b22;
    border: 1px solid #30363d;
}

body.developer-mode .dropdown-content a {
    color: #e6edf3;
    background-color: #161b22;
}

body.developer-mode .dropdown-content a:hover {
    background-color: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
}

/* Developer mode mobile sidebar */
@media (max-width: 900px) {
    body.developer-mode .header-nav {
        background: #0d1117;
    }
}

/* Developer mode content text overrides for blog pages */
body.developer-mode .post-content,
body.developer-mode .post-content p,
body.developer-mode .post-content li,
body.developer-mode .post-content h3,
body.developer-mode .post-content strong {
    color: #ffffff;
}

body.developer-mode .content-article p,
body.developer-mode .content-article li {
    color: #e6edf3;
}

body.developer-mode .faq-question {
    background: #161b22;
    color: #e6edf3;
    border-bottom-color: #30363d;
}

body.developer-mode .faq-answer {
    background: #0d1117;
    color: #e6edf3;
}

/* Developer mode tool-card text for blog listing */
body.developer-mode .tool-card div,
body.developer-mode .tool-card p {
    color: #e6edf3;
}

/* Card - Generic */
.card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card h3 {
    margin: 6px 0
}

/* Primary Button (Non-absolute) */
.primary-btn {
    background: var(--primary-btn-bg);
    border: 1px solid var(--primary-btn-bg);
    color: var(--primary-btn-text);
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

.primary-btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.primary-btn:disabled {
    background: #93c5fd;
    border-color: #93c5fd;
    cursor: not-allowed;
}

/* General Content Styling */
.content-article {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    /* Fix tab width stability - ensure consistent width during tab switching */
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.content-article h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.content-article p {
    font-size: 16px;
    line-height: 1.8;
    color: #444;
    margin-bottom: 16px;
}

.content-article ul {
    list-style: none;
    padding: 0;
}

.content-article li {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    line-height: 1.6;
}

.content-article li:last-child {
    border-bottom: none;
}

.content-article li strong {
    color: #2196F3;
    display: block;
    margin-bottom: 4px;
}

/* Tabs Generic */
.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #2874A6;
    background: rgba(40, 116, 166, 0.05);
}

.tab-btn.active {
    color: #2874A6;
    border-bottom-color: #2874A6;
    background: rgba(40, 116, 166, 0.08);
}

.tab-panel {
    display: none;
    animation: fadeInTab 0.4s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* FAQ Item Generic */
.faq-item {
    margin-bottom: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    border-color: #2874A6;
    box-shadow: 0 2px 8px rgba(40, 116, 166, 0.1);
}

.faq-question {
    font-weight: 600;
    font-size: 16px;
    padding: 16px 20px;
    background: #f8f9fa;
    color: #1a1a1a;
    border-bottom: 1px solid #e0e0e0;
}

.faq-answer {
    padding: 16px 20px;
    font-size: 15px;
    line-height: 1.7;
    color: #444;
    background: white;
}

/* Loading & Error */
.loading {
    color: #666
}

.error {
    color: #9b1b1b;
    background: #fff4f4;
    padding: 8px;
    border-radius: 6px
}

/* Footer */
footer {
    background: #2c2c2c;
    color: #999;
    text-align: center;
    padding: 40px 24px;
    margin-top: 80px
}

footer .container {
    max-width: 1200px;
    margin: 0 auto;
}

footer p {
    margin: 8px 0;
}

/* Logic for Dark Mode Overrides (Generic) */
body.dark-mode .content-article p,
body.dark-mode .content-article li,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: var(--text-color);
}

body.dark-mode .content-article ul li strong {
    color: var(--link-color);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}