/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* CSS Custom Properties for Theming */
:root {
    /* Light Theme Variables */
    --bg-color: #f8fafc;
    --text-color: #1f2937;
    --primary-color: #2563eb;
    --secondary-text: #4b5563;
    --muted-text: #6b7280;

    /* Layout */
    --header-bg: #ffffff;
    --header-shadow: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --border-color: #e5e7eb;

    /* Buttons */
    --btn-primary: #2563eb;
    --btn-primary-hover: #1d4ed8;
    --btn-secondary: #f3f4f6;
    --btn-secondary-hover: #e5e7eb;
    --btn-outline: #2563eb;
    --btn-outline-hover: #2563eb;
    --btn-outline-hover-bg: #2563eb;

    /* Results */
    --result-bg: #f0f9ff;
    --result-border: #0ea5e9;
    --result-text: #0c4a6e;
    --result-value: #0369a1;

    /* Footer */
    --footer-bg: #1f2937;
    --footer-text: #ffffff;

    /* Modals */
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --modal-bg: #ffffff;

    /* Form Elements */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-text: #1f2937;
    --input-focus-border: #2563eb;
    --input-focus-shadow: rgba(37, 99, 235, 0.1);

    /* Navigation */
    --nav-link-color: #1f2937;
    --nav-link-hover: #2563eb;
    --nav-link-active: #2563eb;

    /* Special Elements */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
}

.dark-theme {
    --bg-color: #1f2937;
    --text-color: #f9fafb;
    --header-bg: #111827;
    --header-shadow: rgba(0, 0, 0, 0.3);
    --card-bg: #374151;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --btn-primary: #3b82f6;
    --btn-primary-hover: #2563eb;
    --btn-outline: #60a5fa;
    --btn-outline-hover: #60a5fa;
    --btn-outline-hover-bg: #60a5fa;
    --result-bg: #1e40af;
    --result-border: #3b82f6;
    --result-text: #dbeafe;
    --result-value: #93c5fd;
    --footer-bg: #111827;
    --footer-text: #f9fafb;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --modal-bg: #374151;
    --secondary-text: #d1d5db;
    --input-bg: #374151;
    --input-border: #4b5563;
    --input-text: #f9fafb;
}

/* Dark theme footer links override for better visibility */
.dark-theme .footer-links a:hover,
.dark-theme .footer-contact a:hover {
    color: #93c5fd;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    font-display: swap; /* Improve font loading performance */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #2563eb;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    font-weight: 500;
    transition: top 0.2s ease;
    border: 2px solid transparent;
    font-size: 14px;
}

.skip-link:focus {
    top: 6px;
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    border-color: #ffffff;
}

/* Screen Reader Only Text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Management */
.focus-visible:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --text-color: #000000;
        --bg-color: #ffffff;
        --card-bg: #ffffff;
        --border-color: #000000;
    }

    .dark-theme {
        --primary-color: #ffff00;
        --text-color: #ffffff;
        --bg-color: #000000;
        --card-bg: #000000;
        --border-color: #ffffff;
    }
}

/* Dark Mode Support - Only applied when .dark-theme class is present */
/* Removed conflicting @media (prefers-color-scheme: dark) query */
/* Theme switching is now handled exclusively by JavaScript and .dark-theme class */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.btn:focus {
    outline-color: #2563eb;
}

.btn-primary {
    background-color: var(--btn-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

.btn-outline {
    background-color: transparent;
    color: var(--btn-outline);
    border: 2px solid var(--btn-outline);
}

.btn-outline:hover {
    background-color: var(--btn-outline-hover-bg);
    color: white;
}

/* Header */
.header {
    background-color: var(--header-bg);
    box-shadow: 0 1px 3px var(--header-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.header-hidden {
    transform: translateY(-100%);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2563eb;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin-left: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: #2563eb;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #2563eb;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: 0.25rem;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.lang-btn:hover,
.lang-btn.active {
    background-color: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* Main Content */
.main {
    min-height: calc(100vh - 200px);
}

/* Sections */
.section {
    padding: 4rem 0;
    display: none;
}

.section.active {
    display: block;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 4rem;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--secondary-text);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle,
.history-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
    color: var(--text-color);
}

.theme-toggle:hover,
.history-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.feature-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--card-shadow);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* Calculators Grid */
.calculators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.calculator-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.calculator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--card-shadow);
}

.calculator-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.calculator-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.calculator-card p {
    color: var(--secondary-text);
    margin-bottom: 1.5rem;
}

/* Calculator View */
.calculator-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.back-btn {
    background: none;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
}

.back-btn:hover {
    background-color: var(--card-bg);
    border-color: var(--input-border);
}

.calculator-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
}

/* About Section */
.about-content {
    max-width: 1200px;
    margin: 0 auto;
}

.about-intro {
    text-align: center;
    margin-bottom: 3rem;
}

.about-intro h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.about-intro p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.about-benefits {
    margin-bottom: 3rem;
}

.about-benefits h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.benefit-item {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    text-align: center;
    transition: transform 0.2s ease;
}

.benefit-item:hover {
    transform: translateY(-2px);
}

.benefit-item h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.benefit-item p {
    color: var(--secondary-text);
    line-height: 1.5;
}

.about-categories {
    margin-bottom: 3rem;
}

.about-categories h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.categories-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.category-group {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    border-left: 4px solid var(--primary-color);
}

.category-group h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.category-group p {
    color: var(--secondary-text);
    line-height: 1.5;
    margin: 0;
}

.about-features {
    margin-bottom: 3rem;
}

.about-features h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.about-features ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.about-features li {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    position: relative;
    padding-left: 3rem;
    display: flex;
    align-items: center;
}

.about-features li::before {
    content: '✓';
    position: absolute;
    left: 1rem;
    color: #10b981;
    font-weight: bold;
    font-size: 1.2rem;
}

.about-features li strong {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.about-cta {
    text-align: center;
    margin-bottom: 3rem;
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    padding: 3rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.about-cta h3 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.about-cta p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    opacity: 0.9;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    text-align: center;
}

.stat-item {
    background: var(--card-bg);
    padding: 2rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
}

.stat-item strong {
    display: block;
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-item span {
    color: var(--secondary-text);
    font-weight: 500;
}

/* Responsive adjustments for about section */
@media (max-width: 768px) {
    .benefits-grid,
    .categories-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .about-features ul {
        grid-template-columns: 1fr;
    }

    .about-cta {
        padding: 2rem 1rem;
    }

    .about-cta h3 {
        font-size: 1.5rem;
    }

    .about-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-item {
        padding: 1.5rem 0.5rem;
    }

    .stat-item strong {
        font-size: 2rem;
    }
}

/* Footer */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-links,
.footer-contact {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

/* Footer Links Styling */
.footer-links a,
.footer-contact a {
    color: var(--footer-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover,
.footer-contact a:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.footer-section h4 {
    color: var(--footer-text);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.footer-section p {
    color: var(--footer-text);
    opacity: 0.9;
    line-height: 1.5;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
}

.modal[aria-hidden="false"] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
}

.modal-content {
    position: relative;
    background: var(--modal-bg);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--input-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: var(--input-bg);
}

.modal-body {
    padding: 1.5rem;
}

.history-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.file-input-label {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--input-border);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    font-weight: 500;
}

.file-input-label:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    background: var(--card-bg);
}

.history-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--text-color);
}

.history-item p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: var(--secondary-text);
}

.history-item .timestamp {
    font-size: 0.75rem;
    color: var(--secondary-text);
}

/* Sharing buttons */
.share-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.share-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.25rem;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.share-btn:hover {
    background-color: var(--card-bg);
    border-color: var(--input-border);
}

/* Hero Enhancements */
.hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #92400e;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--secondary-text);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.hero-highlights {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.highlight-item {
    text-align: center;
    min-width: 100px;
}

.highlight-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.highlight-text {
    font-size: 0.875rem;
    color: var(--secondary-text);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-large {
    padding: 1.5rem 3rem;
    font-size: 1.375rem;
    font-weight: 600;
}

.btn-icon {
    margin-right: 0.5rem;
}

.hero-trust {
    text-align: center;
    margin-bottom: 3rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 1px 3px var(--card-shadow);
}

.trust-stars {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: #fbbf24;
}

.hero-trust p {
    color: var(--secondary-text);
    font-size: 0.875rem;
    margin: 0;
}

.hero-categories {
    margin-top: 4rem;
    text-align: center;
}

.hero-categories h2 {
    color: var(--text-color);
    margin-bottom: 2rem;
    font-size: 2rem;
}

.categories-preview {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.category-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 120px;
}

.category-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--card-shadow);
}

.category-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.category-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
}

/* Calculators Page Enhancements */
.calculators-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
    gap: 2rem;
}

.calculators-title-section h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.calculators-subtitle {
    font-size: 1.125rem;
    color: var(--secondary-text);
    line-height: 1.6;
    max-width: 500px;
}

.calculators-stats {
    display: flex;
    gap: 2rem;
    flex-shrink: 0;
}

.stat-mini {
    text-align: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--card-shadow);
    min-width: 100px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--secondary-text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calculators-controls {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 3rem;
}

.search-box {
    position: relative;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 2px solid var(--input-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    transition: border-color 0.2s ease;
}

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

.search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.search-btn:hover {
    color: var(--primary-color);
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--input-border);
    border-radius: 2rem;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.calculators-featured {
    margin-bottom: 3rem;
}

.calculators-featured h3 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.calculator-card.featured {
    position: relative;
    border: 2px solid #fbbf24;
    background: linear-gradient(135deg, var(--card-bg), #fef3c7);
}

.featured-badge {
    position: absolute;
    top: -0.5rem;
    right: 1rem;
    background: #fbbf24;
    color: #92400e;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
}

.calculator-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--input-border);
}

.usage-count {
    font-size: 0.75rem;
    color: var(--secondary-text);
    font-weight: 500;
}

.rating {
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0;
    }

    .nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .nav-toggle {
        margin-left: auto;
    }

    .nav-list {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
    }

    .nav-list.active {
        display: flex;
    }

    .nav-link {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .nav-list {
        margin-left: 0;
        gap: 1rem;
    }

    .nav-toggle {
        display: block;
        order: 2;
        margin-left: auto;
    }

    .nav-list {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
    }

    .nav-list.active {
        display: flex;
    }

    .nav-link {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .hero {
        text-align: center;
        margin-bottom: 3rem;
        padding: 0 1rem;
    }

    .hero-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .hero-title {
        font-size: 2.5rem;
        line-height: 1.1;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1.125rem;
        line-height: 1.4;
        margin-bottom: 2rem;
        max-width: 100%;
    }

    .hero-highlights {
        gap: 1rem;
    }

    .highlight-item {
        min-width: 80px;
    }

    .highlight-number {
        font-size: 2rem;
    }

    .hero-actions {
        gap: 1rem;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .hero-trust {
        margin-bottom: 2rem;
        padding: 1rem;
    }

    .categories-preview {
        gap: 1rem;
    }

    .category-preview {
        min-width: 100px;
        padding: 1rem;
    }

    .calculators-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .calculators-title-section h2 {
        font-size: 2rem;
    }

    .calculators-stats {
        flex-direction: row;
        gap: 1rem;
        width: 100%;
        justify-content: center;
    }

    .stat-mini {
        min-width: 80px;
        padding: 0.75rem;
    }

    .calculators-controls {
        gap: 1.5rem;
    }

    .search-box {
        max-width: 100%;
    }

    .filter-tabs {
        justify-content: center;
    }

    .filter-tab {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }

    .featured-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0 1rem;
    }

    .feature-card {
        padding: 1.5rem;
        text-align: center;
    }

    .calculators-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }

    .calculator-card {
        padding: 1.5rem;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .calculator-card h3 {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .calculator-card p {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .calculator-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .back-btn {
        align-self: flex-start;
    }

    .calculator-content {
        padding: 1rem;
    }

    .calculator-form {
        max-width: 100%;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .result {
        margin-top: 1.5rem;
        padding: 1rem;
    }

    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
    }

    .modal-body {
        padding: 1rem;
    }

    .history-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .history-item {
        padding: 0.75rem;
    }
}

/* Tablet Styles */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        max-width: 100%;
        padding: 0 2rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.125rem;
        max-width: 80%;
    }

    .calculators-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }

    .calculator-card {
        padding: 1.75rem;
    }

    .features {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Mobile Styles */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .section {
        padding: 2rem 0;
    }

    .hero {
        margin-bottom: 2rem;
        padding: 0 0.5rem;
    }

    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.4;
        margin-bottom: 1.5rem;
    }

    .hero-actions .btn {
        padding: 1.5rem 2rem;
        font-size: 1.25rem;
    }

    .feature-card,
    .calculator-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .feature-card h3,
    .calculator-card h3 {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .feature-card p,
    .calculator-card p {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .calculator-content {
        padding: 1.25rem;
        margin: 0 -0.75rem;
        border-radius: 0;
    }

    .calculator-form {
        padding: 0;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 1rem 0.75rem;
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 44px; /* Minimum touch target */
    }

    .btn {
        min-height: 44px; /* Minimum touch target */
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .result {
        margin: 1.5rem -0.75rem -0.75rem;
        border-radius: 0;
        padding: 1.25rem 1rem;
    }

    .modal-content {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        border-radius: 0.5rem;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1rem 1.25rem;
    }

    /* Matrix calculator mobile optimization */
    .matrix-grid input {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }

    .matrix-cell {
        width: 50px;
        height: 50px;
        line-height: 50px;
        font-size: 0.9rem;
    }

    /* Scientific calculator mobile layout */
    .scientific-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.5rem;
    }

    .scientific-grid .calc-btn {
        padding: 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .calculator-card,
    .feature-card {
        transform: none !important;
    }

    .calculator-card:active,
    .feature-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .nav-link {
        padding: 0.75rem 1rem;
        margin: -0.75rem -1rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .feature-icon,
    .calculator-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        margin-bottom: 1rem;
    }

    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .hero-subtitle {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .section {
        padding: 1rem 0;
    }

    .header-content {
        padding: 0.5rem 0;
    }

    .nav-list {
        padding: 0.5rem;
    }
}

/* Calculator Specific Styles */
.calculator-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

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

.form-group input:invalid,
.form-group select:invalid {
    border-color: #ef4444;
}

.form-group input:invalid:focus,
.form-group select:invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group .error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
}

.form-group.error .error-message {
    display: block;
}

.form-group.error input,
.form-group.error select {
    border-color: #ef4444;
    background-color: #fef2f2;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.result {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--result-bg);
    border: 1px solid var(--result-border);
    border-radius: 0.5rem;
    text-align: center;
}

.result h3 {
    color: var(--result-text);
    margin-bottom: 0.5rem;
}

.result p {
    color: var(--result-value);
    font-size: 1.25rem;
    font-weight: 600;
}

/* Matrix Calculator Styles */
.matrix-input-section {
    margin-bottom: 2rem;
    padding: 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
}

.matrix-input-section h4 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
}

.matrix-grid {
    display: inline-block;
    border: 1px solid var(--input-border);
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.matrix-grid input {
    width: 60px;
    height: 40px;
    border: 1px solid var(--input-border);
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    background: var(--input-bg);
    color: var(--input-text);
    transition: border-color 0.2s ease;
}

.matrix-grid input:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.matrix-grid input:not(:last-child) {
    border-right: none;
}

.matrix-grid br + input {
    border-top: none;
}

.matrix-size-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--secondary-text);
}

.matrix-size-controls select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: 0.25rem;
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--input-text);
}

.matrix-display {
    margin-top: 1rem;
}

.matrix-grid-result {
    display: inline-block;
    border: 2px solid #2563eb;
    border-radius: 0.25rem;
    overflow: hidden;
    background: var(--card-bg);
}

.matrix-cell {
    display: inline-block;
    width: 60px;
    height: 40px;
    border: 1px solid var(--input-border);
    text-align: center;
    line-height: 40px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
    background: var(--card-bg);
}

.matrix-cell:not(:last-child) {
    border-right: none;
}

.matrix-grid-result br + .matrix-cell {
    border-top: none;
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.dark-theme .loading-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.loading-content {
    text-align: center;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--input-border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-text {
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 500;
}

/* Button Loading States */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Success/Error States */
.form-group.success input,
.form-group.success select {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.form-group.success .success-message {
    color: #10b981;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.form-group .success-message {
    display: none;
}

/* Improved Focus Management */
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Better Error Handling */
.error-summary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.error-summary h3 {
    color: #dc2626;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.error-summary ul {
    margin: 0;
    padding-left: 1.5rem;
}

.error-summary li {
    color: #dc2626;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

/* Success Feedback */
.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.success-message p {
    color: #166534;
    margin: 0;
    font-weight: 500;
}

/* Progress Indicators */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--input-border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: var(--card-bg);
    color: var(--text-color);
    text-align: center;
    border-radius: 0.5rem;
    padding: 0.5rem;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    border: 1px solid var(--input-border);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Better Mobile Touch Targets */
@media (max-width: 768px) {
    .btn,
    .calculator-card,
    .feature-card,
    .nav-link,
    .lang-btn,
    .filter-tab {
        min-height: 44px;
        min-width: 44px;
    }

    .search-btn,
    .theme-toggle,
    .history-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .nav,
    .hero-actions,
    .btn {
        display: none !important;
    }

    .section {
        display: block !important;
        padding: 1rem 0;
    }

    body {
        background: white !important;
    }
}

/* Enhanced Modal Styles for Text Sharing */
.text-share-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.text-share-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(2px);
}

.text-share-modal .modal-content {
    position: relative;
    background: var(--modal-bg);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.text-share-modal h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 600;
}

.text-share-modal textarea {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-color);
    background: var(--input-bg);
    resize: vertical;
    margin-bottom: 1.5rem;
}

.text-share-modal .modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Health Check Status Indicator */
#pwa-health-status {
    font-size: 0.75rem;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Result Animations */
.result {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top;
}

.result.show {
    animation: resultSlideIn 0.4s ease;
}

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

/* Performance Metrics Display */
.performance-metrics {
    position: fixed;
    top: 80px;
    right: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.75rem;
    color: var(--muted-text);
    z-index: 999;
    max-width: 200px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.performance-metrics h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    color: var(--text-color);
    font-weight: 600;
}

.performance-metrics .metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.performance-metrics .metric-label {
    color: var(--muted-text);
}

.performance-metrics .metric-value {
    font-weight: 500;
    color: var(--text-color);
}

/* Enhanced Calculator Loading States */
.calculator-loading {
    position: relative;
    pointer-events: none;
}

.calculator-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}

.calculator-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Enhanced Error States */
.calculator-error {
    border: 1px solid var(--error-color);
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.calculator-error .form-group input,
.calculator-error .form-group select {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success States */
.calculator-success .form-group input,
.calculator-success .form-group select {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Enhanced Button States */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:active {
    transform: translateY(1px);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    background: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.back-to-top:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top-icon {
    line-height: 1;
    display: block;
}

/* Dark theme support for back-to-top */
.dark-theme .back-to-top {
    background: var(--btn-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.dark-theme .back-to-top:hover {
    background: var(--btn-primary-hover);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Mobile adjustments for back-to-top */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.125rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .nav,
    .theme-toggle,
    .history-btn,
    .language-selector,
    .install-btn,
    .share-buttons,
    .calculator-loading::after,
    .calculator-loading::before,
    .back-to-top {
        display: none !important;
    }

    .result {
        border: 1px solid #000;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .calculator-form {
        break-inside: avoid;
    }
}
