/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    --bg-color: #ffffff;
    --bg-light: #f9fafb;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --badge-cheap: #10b981;
    --badge-normal: #f59e0b;
    --badge-expensive: #ef4444;
    --success: #10b981;
    --error: #ef4444;
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(to bottom, #f0f4f8 0%, #f9fafb 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header and Navigation */
header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-light);
    padding: 1.25rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: var(--transition);
}

.logo:hover {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    position: relative;
    transition: var(--transition);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--primary-color);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Main content */
main {
    flex: 1;
    padding: 3rem 0;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--text-color) 0%, var(--text-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-light);
    margin-bottom: 2.5rem;
    font-size: 1.125rem;
    font-weight: 400;
}

/* Area selector */
.area-selector {
    margin-bottom: 2rem;
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.area-selector label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.area-selector-row {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.area-selector select {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.area-selector select:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.detect-btn {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.detect-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.detect-btn:hover::before {
    left: 100%;
}

.detect-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.detect-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* Status message */
.status {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    display: none;
    animation: slideDown 0.3s ease-out;
    font-weight: 500;
}

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

.status.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.status.loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.status.error {
    display: block;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Price badges */
.price-badges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.badge {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.badge:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.badge.cheap {
    background: linear-gradient(135deg, var(--badge-cheap) 0%, #059669 100%);
    color: white;
}

.badge.normal {
    background: linear-gradient(135deg, var(--badge-normal) 0%, #d97706 100%);
    color: white;
}

.badge.expensive {
    background: linear-gradient(135deg, var(--badge-expensive) 0%, #dc2626 100%);
    color: white;
}

/* Calculation cards */
.calculations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.calculation-card {
    background: var(--bg-color);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.calculation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transition: var(--transition);
}

.calculation-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.calculation-card:hover::before {
    transform: scaleX(1);
}

.calculation-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--bg-light) 0%, #ffffff 100%);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.price-item:hover {
    background: linear-gradient(135deg, #ffffff 0%, var(--bg-light) 100%);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateX(5px);
}

.price-item .label {
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.95rem;
}

.price-item .price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Graph card */
.graph-card {
    background: var(--bg-color);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.graph-card:hover {
    box-shadow: var(--shadow-lg);
}

.graph-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.graph-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--bg-light) 0%, #ffffff 100%);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

#price-graph {
    width: 100%;
    height: auto;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.graph-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

.graph-tooltip.visible {
    opacity: 1;
}

.graph-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
}

.graph-note {
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Info box */
.info-box {
    background: var(--bg-color);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--primary-color);
}

.info-box h3 {
    margin-bottom: 1.25rem;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 700;
}

.info-box ul {
    list-style: none;
    color: var(--text-light);
}

.info-box li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    line-height: 1.8;
}

.info-box li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.5rem;
}

.info-box li strong {
    color: var(--text-color);
    font-weight: 600;
}

.info-box h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-weight: 700;
}

.info-box h2:first-child {
    margin-top: 0;
}

.info-box a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.info-box a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.button-link {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.button-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Footer */
footer {
    background: var(--bg-color);
    border-top: 1px solid var(--border-light);
    padding: 2.5rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-light);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

footer a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-color);
}

footer a:hover::after {
    width: 100%;
}

footer p {
    margin-bottom: 0.75rem;
}

footer p:last-child {
    margin-bottom: 0;
}

.version-info {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-lighter);
    font-family: 'Courier New', monospace;
}

.version-info #version {
    font-weight: 600;
    color: var(--primary-color);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .nav-links {
        gap: 1.25rem;
        font-size: 0.9rem;
    }

    .area-selector {
        padding: 1.25rem;
    }

    .area-selector-row {
        flex-direction: column;
    }

    .detect-btn {
        width: 100%;
    }

    .price-badges {
        grid-template-columns: 1fr;
    }

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

    .calculation-card {
        padding: 1.5rem;
    }

    .graph-card {
        padding: 1.5rem;
    }

    .graph-container {
        padding: 0.75rem;
    }

    #price-graph {
        height: 250px;
    }

    .price-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .price-item .price {
        font-size: 1.75rem;
    }

    main {
        padding: 2rem 0;
    }
}

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

    main {
        padding: 1.5rem 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .logo {
        font-size: 1.25rem;
    }

    header {
        padding: 1rem 0;
    }

    .calculation-card {
        padding: 1.25rem;
    }

    .info-box {
        padding: 1.5rem;
    }
}

/* Loading animation for price updates */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.price-item {
    animation: fadeIn 0.4s ease-out;
}

/* Smooth transitions for all interactive elements */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
