/* Global Styles & Variables */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, 0.09);
    --bg-color: #f4f5f7;
    --text-color: #0f172a;
    --muted-text: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
}

:root[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --muted-text: #94a3b8;
    --card-bg: #1e293b;
    --border-color: #334155;
    --border-strong: #475569;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Navbar Styling */
.navbar {
    background-color: var(--card-bg);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.logo-link,
.logo-link:link,
.logo-link:visited,
.logo-link:hover,
.logo-link:active,
.logo-link:focus {
    text-decoration: none !important;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px;
}

.logo-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: #4f46e5;
    color: #ffffff;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.22);
}

.logo-badge svg {
    width: 22px;
    height: 22px;
    display: block;
    stroke: #ffffff;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-color);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
}

.logo span {
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 22px;
}

.nav-links a {
    position: relative;
    text-decoration: none;
    color: var(--muted-text);
    font-weight: 500;
    font-size: 0.96rem;
    padding: 4px 0;
    background: transparent;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
    background: transparent;
    font-weight: 600;
}

.nav-links a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    border-radius: 999px;
    background-color: var(--primary-color);
}

/* Mobile 3-Line Menu Button & Drawer */
.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.mobile-menu-btn:hover {
    background-color: var(--primary-soft);
    border-color: var(--primary-color);
}

.mobile-menu-btn .menu-line {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background-color: var(--text-color);
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.mobile-menu-btn[aria-expanded="true"] .menu-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-btn[aria-expanded="true"] .menu-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn[aria-expanded="true"] .menu-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.mobile-nav-drawer {
    display: none;
}

@media (max-width: 768px) {
    .navbar {
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        padding: 0.85rem 1rem;
        gap: 0.5rem;
    }

    .logo {
        width: auto;
        flex: 1;
        min-width: 0;
        display: flex;
        justify-content: flex-start;
    }

    .logo-link,
    .logo-link:link,
    .logo-link:visited,
    .logo-link:hover,
    .logo-link:active,
    .logo-link:focus {
        justify-content: flex-start !important;
        max-width: 100%;
    }

    .logo-badge {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

    .logo h1 {
        font-size: 1.24rem;
        text-align: left;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .mobile-nav-drawer {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: 0.5rem 0 0.25rem;
        margin-top: 0.35rem;
        border-top: 1px solid var(--border-color);
    }

    .mobile-nav-drawer.is-open {
        display: flex;
    }

    .mobile-nav-drawer a {
        text-decoration: none;
        color: var(--text-color);
        font-weight: 500;
        font-size: 0.95rem;
        padding: 0.65rem 0.4rem;
        border-bottom: 1px solid var(--border-color);
        transition: color 0.2s ease;
    }

    .mobile-nav-drawer a:last-child {
        border-bottom: none;
    }

    .mobile-nav-drawer a:hover {
        color: var(--primary-color);
    }

    .nav-links {
        justify-content: center;
        gap: 10px 16px;
        font-size: 0.9rem;
    }

    .nav-links a {
        padding: 4px 2px;
    }
}

/* Footer Styling */
.site-footer,
footer {
    width: 100%;
    padding: 1.35rem 5%;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    color: var(--muted-text);
    font-size: 0.88rem;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

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

.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 22px;
}

.footer-links a {
    text-decoration: none;
    color: var(--muted-text);
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-bottom-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-copyright {
    margin: 0;
    color: var(--muted-text);
    text-align: left;
}

/* Theme Selector (Light / Dark / System) */
.theme-switcher {
    position: relative;
    display: inline-block;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.theme-btn:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-soft);
}

.theme-btn-left {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.theme-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    min-width: 145px;
    list-style: none;
    padding: 0.35rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    box-shadow: var(--shadow-md);
    z-index: 50;
}

.theme-menu.is-open {
    display: block;
}

.theme-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.48rem 0.65rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-color);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.theme-option:hover {
    background-color: var(--primary-soft);
    color: var(--primary-color);
}

.theme-option.is-active {
    color: var(--primary-color);
    font-weight: 600;
    background-color: var(--primary-soft);
}

@media (max-width: 640px) {
    .site-footer,
    footer {
        padding: 1.2rem 1rem;
    }

    .footer-bottom-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
