/* ==========================
   ROOT VARIABLES & THEMES
========================= */
:root {
    --primary: #000000;
    --primary-hover: #1d4ed8;
    --secondary: #1e40af;
    --accent: #06b6d4;
    
    --bg: #f8fafc;
    --text: #1f2937;
    --text-muted: #6b7280;
    
    --sidebar-bg: #ffffff;
    --sidebar-item: #f3f4f6;
    --sidebar-text: #1f2937;
    --sidebar-active-bg: #2563eb;
    --sidebar-active-text: #ffffff;
    
    --btn-bg: #f1f5f9;
    --btn-text: #334155;
    --display-bg: #ffffff;
    --display-text: #0f172a;

    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(226, 232, 240, 0.8);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

body.dark {
    --bg: #0f172a;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    
    --sidebar-bg: #1e293b;
    --sidebar-item: #334155;
    --sidebar-text: #f1f5f9;
    --sidebar-active-bg: #38bdf8;
    --sidebar-active-text: #0f172a;
    
    --btn-bg: #334155;
    --btn-text: #f8fafc;
    --display-bg: #1e293b;
    --display-text: #f8fafc;

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

/* ==========================
   BASE RESET
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    outline: none;
}

/* ==========================
   GLASS EFFECT
========================= */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: var(--shadow);
}

/* ==========================
   HEADER
========================= */
.header {
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 24px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark .logo {
    color: var(--sidebar-active-bg);
}

.nav {
    display: flex;
    gap: 24px;
}

.nav a {
    font-weight: 600;
    transition: color 0.3s;
    font-size: 0.95rem;
}

.nav a:hover, .nav a.active-nav {
    color: var(--primary);
}
body.dark .nav a:hover, body.dark .nav a.active-nav {
    color: var(--sidebar-active-bg);
}

.header-actions {
    display: flex;
    align-items: center;
}

.header-actions button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--btn-bg);
    color: var(--text);
    margin-left: 8px;
    transition: transform 0.2s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.header-actions button:hover {
    transform: translateY(-2px);
    background: var(--glass-border);
}

.menu-btn {
    display: none;
}

/* ==========================
   LAYOUT STRUCTURE
========================= */
.container {
    display: flex;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
}

/* ==========================
   SIDEBAR
========================= */
.sidebar {
    width: 280px;
    padding: 24px 16px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    transition: width 0.3s ease, transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 75px;
}

.sidebar.collapsed h3, 
.sidebar.collapsed span {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-left: 8px;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.sidebar-header button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--btn-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.sidebar.collapsed #sidebarToggle {
    transform: rotate(180deg);
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    border-radius: 10px;
    margin-bottom: 6px;
    transition: background 0.2s, color 0.2s;
    background: var(--sidebar-item);
}

.sidebar li a {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: var(--sidebar-text);
    font-weight: 500;
    width: 100%;
    border-radius: 10px;
}

.icon-gap {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar li:hover {
    background: var(--glass-border);
}

.sidebar li.active {
    background: var(--sidebar-active-bg) !important;
}

.sidebar li.active a {
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
}

/* ==========================
   MAIN CONTENT
========================= */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-x: hidden;
}

/* ==========================
   HERO SECTION
========================= */
.hero {
    padding: 50px 32px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 30px;
}

.hero h1 {
    font-size: 2.4rem;
    margin-bottom: 12px;
    font-weight: 800;
}

.hero p {
    max-width: 650px;
    margin: 0 auto 24px;
    line-height: 1.7;
    color: var(--text-muted);
}

.cta-btn {
    padding: 14px 28px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    transition: background 0.2s, transform 0.2s;
}

.cta-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* ==========================
   FEATURES CARD GRID
========================= */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.feature-card {
    padding: 30px 20px;
    text-align: center;
    border-radius: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
}

.feature-card i {
    font-size: 2.2rem;
    color: var(--primary);
    margin-bottom: 14px;
}
body.dark .feature-card i {
    color: var(--sidebar-active-bg);
}

.feature-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

/* ==========================
   ADVANCED CALCULATOR SECTION
========================= */
.calculator-section {
    padding: 28px;
    border-radius: 24px;
    margin-bottom: 30px;
}

.calculator-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 700;
    text-align: center;
}

.calculator {
    max-width: 480px;
    margin: 0 auto;
}

#display {
    width: 100%;
    padding: 20px;
    font-size: 2rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--display-bg);
    color: var(--display-text);
    text-align: right;
    outline: none;
    margin-bottom: 16px;
    font-weight: 600;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.button-grid button {
    padding: 16px 10px;
    font-size: 1.05rem;
    border-radius: 12px;
    background: var(--btn-bg);
    color: var(--btn-text);
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.button-grid button:hover {
    background: #e2e8f0;
}
body.dark .button-grid button:hover {
    background: #475569;
}

.button-grid .btn-clear {
    background: #ef4444;
    color: #ffffff;
}
.button-grid .btn-clear:hover {
    background: #dc2626;
}

.button-grid .btn-func {
    background: #e2e8f0;
    color: #475569;
}
body.dark .button-grid .btn-func {
    background: #1e293b;
    color: #94a3b8;
}

.button-grid .btn-op {
    background: #dbeafe;
    color: #1e40af;
}
body.dark .button-grid .btn-op {
    background: #1e293b;
    color: #38bdf8;
}

.button-grid .equal-btn {
    grid-column: span 2;
    background: var(--primary) !important;
    color: #ffffff !important;
}
.button-grid .equal-btn:hover {
    background: var(--primary-hover) !important;
}

.calc-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.calc-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    background: var(--btn-bg);
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.calc-actions button:hover {
    background: var(--glass-border);
}

/* ==========================
   HISTORY LIST
========================= */
.history {
    padding: 24px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.history h3 {
    margin-bottom: 14px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

#historyList {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

#historyList li {
    padding: 10px 12px;
    border-bottom: 1px solid var(--glass-border);
    font-family: inherit;
}

/* ==========================
   PAGE SECTIONS (FAQ, About, Contact)
========================= */
.page-section {
    padding: 28px;
    border-radius: 24px;
    margin-bottom: 30px;
}

.faq-item {
    margin-top: 20px;
}

.faq-item h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

/* ==========================
   FOOTER (FIXED)
========================= */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 24px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--glass-border);
    margin-top: 40px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

/* ==================================================
   MOBILE RESPONSIVE MEDIA QUERIES (Under 992px)
================================================== */
@media (max-width: 992px) {
    .menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--glass-border);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        box-shadow: var(--shadow);
        z-index: 1000;
    }

    .nav.show {
        display: flex;
    }

    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 20px 16px;
    }

    .sidebar ul {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 8px;
    }

    .sidebar li {
        margin-bottom: 0;
    }

    #sidebarToggle {
        display: none;
    }

    .main-content {
        padding: 20px 16px;
    }

    .hero h1 {
        font-size: 1.9rem;
    }
    
    .footer {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}