/* ===== CSS Variables ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Optional: Use background image if available */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.6;
    z-index: -1;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== Card Styles ===== */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.card h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Sections ===== */
section {
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out;
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.label-text {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.label-hint {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

input[type="number"] {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    background: var(--bg-white);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="number"]:hover {
    border-color: var(--primary-dark);
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* ===== Button Styles ===== */
.btn-calculate {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark), #6d28d9);
}

.btn-calculate:active {
    transform: translateY(0);
}

/* ===== Results Styles ===== */
.results {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #eff6ff, #f5f3ff);
    border-radius: var(--radius-lg);
    border: 2px solid var(--primary-color);
    animation: slideIn 0.5s ease-out;
}

.results.hidden {
    display: none;
}

.results h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.result-item {
    background: var(--bg-white);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s ease;
}

.result-item:hover {
    transform: scale(1.02);
}

.result-item.highlight {
    background: linear-gradient(135deg, #dbeafe, #ede9fe);
    border: 2px solid var(--primary-color);
}

.result-item.total {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.result-item.total .result-label,
.result-item.total .result-value {
    color: white;
}

.result-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-value.success {
    color: var(--success-color);
}

/* ===== Formula Styles ===== */
.formula-item {
    margin-bottom: 2rem;
}

.formula-item:last-child {
    margin-bottom: 0;
}

.formula-item h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.formula-box {
    background: linear-gradient(135deg, #1e293b, #334155);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    box-shadow: var(--shadow-md);
}

.formula-box code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    color: #fbbf24;
    line-height: 1.8;
    display: block;
}

.formula-desc {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.highlight-formula {
    background: linear-gradient(135deg, #eff6ff, #f5f3ff);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary-color);
}

/* ===== Example Styles ===== */
.example-item {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border-left: 4px solid var(--success-color);
}

.example-item:last-child {
    margin-bottom: 0;
}

.example-item h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.example-params,
.example-calc {
    margin-bottom: 1rem;
}

.example-params p,
.example-calc p {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.example-params ul,
.example-calc ol {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.example-params li,
.example-calc li {
    margin-bottom: 0.5rem;
}

.example-result {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--success-color);
    text-align: center;
}

.highlight-text {
    color: var(--primary-color);
    font-weight: 700;
}

.success-text {
    color: var(--success-color);
    font-weight: 700;
}

/* ===== Explanation Styles ===== */
.explanation-item {
    margin-bottom: 2rem;
}

.explanation-item:last-child {
    margin-bottom: 0;
}

.explanation-item h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.explanation-item h4 {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin: 1rem 0 0.5rem 0;
}

.explanation-item p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.explanation-item ul {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.explanation-item li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.explanation-item li strong {
    color: var(--text-primary);
}

/* ===== Ad Section ===== */
.ad-section {
    margin: 2rem 0;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

footer p {
    margin-bottom: 0.5rem;
}

.disclaimer {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== Animations ===== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .card h2 {
        font-size: 1.5rem;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 1rem 0.75rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.25rem;
    }

    .btn-calculate {
        font-size: 1rem;
    }

    .result-value {
        font-size: 1.25rem;
    }
}
