/* ==========================================================================
   AnyCalc - Minimal Design System
   Clean, modern, minimalist styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Base Styles
   -------------------------------------------------------------------------- */
html {
    scroll-behavior: smooth;
}

body {
    background: #ffffff;
    color: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Dark Theme Overrides (scoped to pages adding `theme-dark` to <body>)
   -------------------------------------------------------------------------- */
body.theme-dark {
    background: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .section-header {
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   Minimal Card Style
   -------------------------------------------------------------------------- */
.glass-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.glass-card-hover {
    transition: all 0.2s ease;
}

.glass-card-hover:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

/* --------------------------------------------------------------------------
   Calculator Card (Homepage)
   -------------------------------------------------------------------------- */
.calculator-card {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.calculator-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

/* Dark override for cards */
body.theme-dark .calculator-card {
    background: #0b1220;
    border: 1px solid #1e293b;
    color: #e2e8f0;
}

body.theme-dark .calculator-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    border-color: #3b82f6;
}

body.theme-dark .calculator-card h3 {
    color: #ffffff;
}

body.theme-dark .calculator-card p {
    color: #cbd5e1;
}

/* --------------------------------------------------------------------------
   Accessibility: Skip Link & Focus Styles
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 16px;
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    z-index: 1000;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 12px;
}

/* Stronger focus visibility for keyboard users */
:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 6px;
}

/* --------------------------------------------------------------------------
   Section Headers
   -------------------------------------------------------------------------- */
.section-header {
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
    font-size: 1.875rem;
    font-weight: 700;
    color: #1a1a1a;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 48px;
    height: 3px;
    background: #3b82f6;
    border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Feature Badge
   -------------------------------------------------------------------------- */
.feature-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s;
}

.feature-badge:hover {
    background: rgba(59, 130, 246, 0.2);
    color: white;
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   Search Box
   -------------------------------------------------------------------------- */
.search-box {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
    color: #1a1a1a;
}

.search-box::placeholder {
    color: #9ca3af;
}

.search-box:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* --------------------------------------------------------------------------
   Custom Range Slider
   -------------------------------------------------------------------------- */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

input[type=range]:focus {
    outline: none;
}

/* Webkit (Chrome, Safari, Edge) */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    border: 2px solid #ffffff;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: #2563eb;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 3px;
}

/* Firefox */
input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 3px;
}

/* Accent colors for sliders */
input[type=range].accent-purple::-webkit-slider-thumb {
    background: #8b5cf6;
}

input[type=range].accent-green::-webkit-slider-thumb {
    background: #10b981;
}

input[type=range].accent-purple::-moz-range-thumb {
    background: #8b5cf6;
}

input[type=range].accent-green::-moz-range-thumb {
    background: #10b981;
}

/* --------------------------------------------------------------------------
   Custom Checkbox
   -------------------------------------------------------------------------- */
input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Blog Card
   -------------------------------------------------------------------------- */
.blog-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.card-thumb {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    font-size: 3rem;
}

/* --------------------------------------------------------------------------
   Filter Button (Blog)
   -------------------------------------------------------------------------- */
.filter-btn.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* --------------------------------------------------------------------------
   Error Page Styles
   -------------------------------------------------------------------------- */
.error-text {
    font-size: 10rem;
    line-height: 1;
    font-weight: 900;
    color: #3b82f6;
    opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Ad Placeholder
   -------------------------------------------------------------------------- */
.ad-placeholder {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.ad-placeholder span {
    font-size: 0.75rem;
    color: #9ca3af;
    font-family: ui-monospace, monospace;
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

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

/* --------------------------------------------------------------------------
   Error Message Styles (for form validation)
   -------------------------------------------------------------------------- */
.error-message {
    color: #f87171;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message::before {
    content: '⚠️';
}

.input-error {
    border-color: #f87171 !important;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    color: white;
    font-weight: 500;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
    max-width: 90vw;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success {
    background: #10b981;
}

.toast-error {
    background: #ef4444;
}

.toast-info {
    background: #3b82f6;
}

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

/* --------------------------------------------------------------------------
   Loading Spinner
   -------------------------------------------------------------------------- */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --------------------------------------------------------------------------
   Skip to Content (Accessibility)
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3b82f6;
    color: white;
    padding: 8px 16px;
    z-index: 100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* --------------------------------------------------------------------------
   Homepage Specific Styles
   -------------------------------------------------------------------------- */

/* Feature Badge */
.feature-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s;
}

.feature-badge:hover {
    background: rgba(59, 130, 246, 0.2);
    color: white;
    transform: translateY(-2px);
}

/* Search Box */
.search-box {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(71, 85, 105, 0.5);
    transition: all 0.3s ease;
}

.search-box:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

/* Search Mode Transitions */
.hero-content {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 500px;
    opacity: 1;
    overflow: hidden;
}

.hero-content.hidden-search {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding: 0;
}

header.search-active {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    transition: padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 40;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

/* Keyboard Shortcuts Modal */
.shortcuts-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.shortcuts-modal.visible {
    opacity: 1;
    visibility: visible;
}

/* Recent Calculators */
.recent-calc-tag {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #93c5fd;
    transition: all 0.2s;
}

.recent-calc-tag:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

/* Category filter pills */
.filter-pill {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid rgba(71, 85, 105, 0.5);
    background: rgba(30, 41, 59, 0.5);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover,
.filter-pill.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
}

/* Search results counter */
.search-results-count {
    transition: all 0.3s ease;
}

/* PWA install banner */
.pwa-banner {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(10px);
}

/* Recently used section */
.recent-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px dashed rgba(71, 85, 105, 0.5);
}

.recent-card:hover {
    border-style: solid;
    border-color: rgba(59, 130, 246, 0.5);
}

/* Scroll progress indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    z-index: 100;
    transition: width 0.1s ease-out;
}

/* No results state */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
}

/* Offline indicator */
.offline-banner {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.875rem;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 45;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

/* Random button pulse */
.pulse-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.kbd-hint {
    animation: fadeInUp 0.3s ease;
}
