/* CSS переменные для современного дизайна */
:root {
    /* Нейтральная палитра */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    
    /* Текст */
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    /* Границы */
    --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);
    
    /* Акценты */
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Радиусы */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Размеры */
    --container-max: 1200px;
    --header-height: 80px;
}

/* Темная тема */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #475569;
    --border-light: #334155;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    min-height: var(--header-height);
    padding: 16px 0;
}

.nav {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-shrink: 0;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-link:hover {
    color: var(--text-primary);
}

.logo {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Переключатель темы */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.theme-icon {
    font-size: 1.25rem;
}

/* Main */
.main {
    padding: 48px 0;
}

/* Calculator Grid */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 48px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

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

.card h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Form */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.form-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input:invalid {
    border-color: var(--error);
}

.form-group.success input {
    border-color: var(--success);
}

.form-group.error input {
    border-color: var(--error);
}

.unit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* Results */
.results {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Color indicators for results */
.results.good {
    border-left: 4px solid var(--success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-tertiary) 100%);
    position: relative;
}

.results.good::before {
    content: "✅ ВЫГОДНО";
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.results.avg {
    border-left: 4px solid var(--warning);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, var(--bg-tertiary) 100%);
    position: relative;
}

.results.avg::before {
    content: "⚠️ СРЕДНЕ";
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--warning);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.results.bad {
    border-left: 4px solid var(--error);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, var(--bg-tertiary) 100%);
    position: relative;
}

.results.bad::before {
    content: "❌ НЕВЫГОДНО";
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--error);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Results legend */
.results-legend {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.legend-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.legend-item {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.legend-item.good {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.legend-item.avg {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.legend-item.bad {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Saved products table */
.saved-products-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.saved-products-table th,
.saved-products-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.saved-products-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.saved-products-table tr:hover {
    background: var(--border-light);
}

.saved-products-table .profitability-good {
    color: var(--success);
    font-weight: 600;
}

.saved-products-table .profitability-avg {
    color: var(--warning);
    font-weight: 600;
}

.saved-products-table .profitability-bad {
    color: var(--error);
    font-weight: 600;
}

.saved-products-table .product-name {
    font-weight: 600;
    color: var(--text-primary);
}

.saved-products-table .product-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.saved-products-table .product-link:hover {
    text-decoration: underline;
}

.saved-products-table .actions {
    display: flex;
    gap: 8px;
}

.saved-products-table .btn-small {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 24px;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.result-item:last-child {
    border-bottom: none;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.result-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.result-value {
    color: var(--text-primary);
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* Info Section */
.info-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.formulas {
    display: grid;
    gap: 24px;
}

.formula-item {
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.formula-item h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1.125rem;
    font-weight: 600;
}

.formula {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.formula-item.total {
    background: var(--primary);
    color: white;
}

.formula-item.total h3 {
    color: white;
}

.formula-item.total .formula {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 32px 0;
    margin-top: 48px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px 0;
    }
    
    .logo {
        width: 100%;
    }
    
    .nav {
        align-self: flex-end;
    }
    
    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .card {
        padding: 24px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 16px 0;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .saved-products-table {
        font-size: 0.875rem;
    }
    
    .saved-products-table th,
    .saved-products-table td {
        padding: 8px 12px;
    }
    
    .saved-products-table .product-link {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 32px 0;
    }
    
    .card {
        padding: 20px;
    }
    
    .formula-item {
        padding: 16px;
    }
    
    .saved-products-table {
        font-size: 0.75rem;
    }
    
    .saved-products-table th,
    .saved-products-table td {
        padding: 6px 8px;
    }
    
    .saved-products-table .actions {
        flex-direction: column;
        gap: 4px;
    }
} 