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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

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

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    padding: 2rem 2rem 3rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: 1rem;
}

/* Header left: logo + title inline */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* tight spacing so logo acts like an icon */
}

/* Logo */
.logo-area {
    display: flex;
    align-items: center;
}

.header-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.85);
    animation: logoPop 700ms ease-out, logoFloat 6s ease-in-out infinite;
    transform-origin: center;
    transition: transform 220ms ease, box-shadow 220ms ease, filter 220ms ease;
}

.header-logo:hover {
    transform: translateY(-2px) rotate(-2deg) scale(1.03);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.16);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.45));
}

@keyframes logoPop {
    0% { opacity: 0; transform: scale(0.85) translateY(8px); }
    60% { opacity: 1; transform: scale(1.06) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes logoFloat {
    0% { transform: translateY(0) }
    50% { transform: translateY(-4px) }
    100% { transform: translateY(0) }
}

header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lang-btn.active {
    background: white;
    color: var(--primary-color);
    border-color: white;
    font-weight: 600;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    background: var(--surface);
    margin: -2rem 1rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Navigation */
.calculator-nav {
    background: #f1f5f9;
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section h3 {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #e0f2fe;
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

/* Calculator Content */
.calculator-content {
    padding: 2rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.calculator-panel {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-panel h2 {
    color: var(--text-primary);
    font-size: 1.75rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

/* Formula Display */
.formula-section {
    background: #eff6ff;
    border: 2px solid #3b82f6;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.formula-section h3 {
    color: #1e40af;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.formula-display-math {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    text-align: center;
    font-size: 1.2rem;
    overflow-x: auto;
}

.formula-display {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 6px;
}

.formula-display p {
    color: #92400e;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    margin: 0.25rem 0;
}

.formula-display strong {
    color: #78350f;
}

/* Form */
.calculator-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input:hover {
    border-color: #cbd5e1;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Button Group */
.button-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 1024px) {
    .button-group {
        grid-template-columns: 1fr 1fr;
    }
}

.calculate-btn {
    padding: 1rem 2rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.calculate-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculate-btn:active {
    transform: translateY(0);
}

.clear-btn {
    padding: 1rem 2rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.clear-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.clear-btn:active {
    transform: translateY(0);
}

.copy-btn {
    padding: 1rem 2rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.copy-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.copy-btn:active {
    transform: translateY(0);
}

.export-btn {
    padding: 1rem 2rem;
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.export-btn:hover {
    background: #7c3aed;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.export-btn:active {
    transform: translateY(0);
}

.copy-success {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--secondary-color);
    font-weight: 600;
    animation: fadeInOut 2s;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Result Panel */
.result-panel {
    background: #f0fdf4;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-panel > h3 {
    color: #166534;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.result-value {
    color: #14532d;
    font-size: 1.1rem;
    line-height: 1.8;
}

.result-value strong {
    color: #15803d;
    font-size: 1.3rem;
}

.result-item {
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--secondary-color);
}

/* Detailed Results */
.detailed-results {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.detailed-results h4 {
    color: #166534;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.detailed-formulas {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.formula-item {
    padding: 1rem;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 3px solid #10b981;
}

/* Results Table */
.table-results {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.table-results h4 {
    color: #166534;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.results-table thead {
    background: #e0f2fe;
}

.results-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #0c4a6e;
    border-bottom: 2px solid #3b82f6;
}

.results-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s;
}

.results-table tbody tr:hover {
    background: #f9fafb;
}

.results-table tbody tr:last-child {
    border-bottom: none;
}

.results-table td {
    padding: 1rem;
    color: #374151;
}

.results-table td:first-child {
    font-weight: 600;
}

.results-table td:last-child {
    color: #059669;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Conclusion */
.conclusion {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.conclusion-text {
    color: #1e40af;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.6;
}

.conclusion-text strong {
    color: #1e3a8a;
    font-size: 1.3rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Floating Help Button */
.help-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    text-decoration: none;
    font-size: 24px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.18), 0 4px 8px rgba(0,0,0,0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    z-index: 1000;
}

.help-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 14px 28px rgba(0,0,0,0.22), 0 8px 10px rgba(0,0,0,0.18);
    filter: brightness(1.05);
}

@media (max-width: 768px) {
    .help-fab {
        right: 14px;
        bottom: 14px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
}

/* Scrollbar Styling */
.calculator-nav::-webkit-scrollbar,
.calculator-content::-webkit-scrollbar {
    width: 8px;
}

.calculator-nav::-webkit-scrollbar-track,
.calculator-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.calculator-nav::-webkit-scrollbar-thumb,
.calculator-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.calculator-nav::-webkit-scrollbar-thumb:hover,
.calculator-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
}

.hamburger-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 50px;
    height: 50px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.hamburger-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.hamburger-btn.active {
    background: var(--secondary-color);
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 250px 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding-top: 80px; /* Space for hamburger menu */
    }

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

    .header-logo {
        width: 48px;
        height: 48px;
        padding: 5px;
        border-radius: 12px;
    }

    header h1 {
        font-size: 1.9rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .language-switcher {
        width: 100%;
        justify-content: center;
    }

    .main-content {
        grid-template-columns: 1fr;
        margin: -1rem 0.5rem 1rem;
    }

    .calculator-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: var(--surface);
        border-right: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 80px 1rem 1rem;
    }

    .calculator-nav.mobile-open {
        left: 0;
    }

    .calculator-content {
        padding: 1.5rem;
        max-height: none;
        width: 100%;
    }

    /* Overlay for mobile menu */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .calculator-form {
        grid-template-columns: 1fr;
    }

    .nav-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }

    .button-group {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .calculate-btn,
    .clear-btn,
    .copy-btn,
    .export-btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .results-table {
        font-size: 0.9rem;
        display: block;
        overflow-x: auto;
    }

    .results-table th,
    .results-table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    .formula-display-math {
        font-size: 1rem;
        padding: 1rem;
    }

    .conclusion-text {
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {
    .calculator-nav,
    .calculate-btn,
    footer {
        display: none;
    }

    .calculator-panel {
        display: block !important;
        page-break-after: always;
    }

    .result-panel {
        border: 2px solid #000;
    }
}

