/* ================================================
   CALCULATOR ONLINE — STYLE
   Auto dark/light mode via prefers-color-scheme
   ================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --bg-input: #f5f6f8;
    --bg-result: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --text-primary: #1a1a2e;
    --text-secondary: #555770;
    --text-muted: #8b8da3;
    --text-on-accent: #ffffff;

    --border-color: #e2e4e9;
    --border-focus: #667eea;

    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Calculator-specific */
    --btn-number-bg: #f0f2f5;
    --btn-number-hover: #e4e6eb;
    --btn-func-bg: #e0e3e8;
    --btn-func-hover: #d0d3d8;
    --btn-operator-bg: #667eea;
    --btn-operator-hover: #5569d4;
    --btn-equals-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --calc-display-bg: #1a1a2e;
    --calc-display-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f1117;
        --bg-secondary: #1a1b23;
        --bg-card: #1e1f2b;
        --bg-card-hover: #252636;
        --bg-input: #252636;
        --bg-result: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

        --text-primary: #e4e6f0;
        --text-secondary: #a0a3b5;
        --text-muted: #6b6e80;
        --text-on-accent: #ffffff;

        --border-color: #2d2e3d;
        --border-focus: #667eea;

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
        --shadow-glow: 0 0 25px rgba(102, 126, 234, 0.2);

        --btn-number-bg: #252636;
        --btn-number-hover: #2d2e42;
        --btn-func-bg: #2d2e42;
        --btn-func-hover: #363750;
        --btn-operator-bg: #667eea;
        --btn-operator-hover: #5569d4;
        --calc-display-bg: #0d0e15;
        --calc-display-text: #e4e6f0;
    }
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    opacity: 0.8;
}

/* ---------- HEADER ---------- */
.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-icon {
    font-size: 1.4rem;
}

.logo-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--accent-primary);
    opacity: 1;
}

/* ---------- AD CONTAINERS ---------- */
.ad-container {
    max-width: 800px;
    margin: 16px auto;
    padding: 0 20px;
    text-align: center;
    overflow: hidden;
}

.ad-top {
    margin-top: 16px;
}

.ad-mid {
    margin: 32px auto;
}

.ad-bottom {
    margin-bottom: 16px;
}

/* ---------- HERO ---------- */
.hero {
    text-align: center;
    padding: 48px 0 24px;
    animation: fadeInUp 0.6s ease-out;
}

.hero h1 {
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

/* ---------- CALCULATOR CARD ---------- */
.calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 32px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.calc-body {
    padding: 24px;
}

.calc-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ---------- CALCULATOR DISPLAY ---------- */
.calc-display {
    background: var(--calc-display-bg);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    text-align: right;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.calc-expression {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    min-height: 1.2em;
    word-break: break-all;
}

.calc-screen {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--calc-display-text);
    word-break: break-all;
    line-height: 1.2;
    transition: var(--transition);
}

/* ---------- CALCULATOR BUTTONS ---------- */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.calc-btn {
    padding: 18px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.calc-btn:active {
    transform: scale(0.95);
}

.calc-btn.number {
    background: var(--btn-number-bg);
    color: var(--text-primary);
}

.calc-btn.number:hover {
    background: var(--btn-number-hover);
}

.calc-btn.func {
    background: var(--btn-func-bg);
    color: var(--text-primary);
}

.calc-btn.func:hover {
    background: var(--btn-func-hover);
}

.calc-btn.operator {
    background: var(--btn-operator-bg);
    color: #ffffff;
}

.calc-btn.operator:hover {
    background: var(--btn-operator-hover);
}

.calc-btn.operator.active {
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.calc-btn.equals {
    background: var(--btn-equals-bg);
    color: #ffffff;
}

.calc-btn.equals:hover {
    opacity: 0.9;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.calc-btn.zero {
    grid-column: span 2;
}

/* ---------- HISTORY ---------- */
.calc-history {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.history-header span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-clear {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.history-clear:hover {
    background: var(--bg-input);
}

.history-list {
    max-height: 150px;
    overflow-y: auto;
}

.history-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

.history-entry {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-entry:hover {
    background: var(--bg-input);
}

.history-expr {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-result {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- CONTENT SECTIONS ---------- */
.content-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.content-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.content-section h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.content-section p {
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.8;
}

.content-section ul {
    list-style: none;
    padding: 0;
}

.content-section ul li {
    padding: 8px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---------- STEPS GRID ---------- */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.step-card {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.step-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.step-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.step-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---------- FAQ ACCORDION ---------- */
.faq-item {
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 18px 0;
    background: none;
    border: none;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.faq-question:hover {
    color: var(--accent-primary);
}

.faq-arrow {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.faq-item.active .faq-arrow {
    transform: rotate(90deg);
    color: var(--accent-primary);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 300px;
    padding-bottom: 18px;
}

.faq-answer p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ---------- FOOTER ---------- */
.site-footer {
    text-align: center;
    padding: 32px 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
}

.site-footer p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.disclaimer {
    font-size: 0.8rem !important;
    max-width: 500px;
    margin: 0 auto;
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .calc-body {
        padding: 16px;
    }

    .calc-screen {
        font-size: 2rem;
    }

    .calc-btn {
        padding: 14px;
        font-size: 1.1rem;
    }

    .calc-buttons {
        gap: 8px;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .content-section {
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .calc-card {
        border-radius: var(--radius-lg);
    }

    .nav-links {
        gap: 16px;
    }

    .nav-links a {
        font-size: 0.8rem;
    }
}

@media (max-width: 380px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .nav-links {
        gap: 10px;
    }

    .calc-btn {
        padding: 12px;
        font-size: 1rem;
    }
}