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

:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-light: #718096;
    --background: #f7fafc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    --border-radius: 12px;
    --border-radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    overflow-x: hidden;
}

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

/* Header */
.header {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 2rem 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" fill="rgba(255,255,255,0.1)"><polygon points="1000,100 1000,0 0,100"/></svg>');
    background-size: cover;
}

.logo {
    position: relative;
    z-index: 2;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #fff, #f0f8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Content */
.main {
    padding: 3rem 0;
}

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

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-weight: 400;
}

/* Content Wrapper */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Calculator Section */
.calculator-section {
    position: relative;
}

.calculator-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.calculator-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.calculator-card h2 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
    text-align: center;
}

/* Form Styles */
.bmi-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-wrapper input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--white);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Input Error States */
.input-wrapper input.error,
.height-inches input.error {
    border-color: #cc0000 !important;
    background-color: #ffe6e6 !important;
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1) !important;
}

.input-wrapper input.error:focus,
.height-inches input.error:focus {
    border-color: #cc0000 !important;
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.2) !important;
}

.input-error-tooltip {
    color: #cc0000;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    animation: fadeIn 0.3s ease;
}

.instant-error-message {
    color: #cc0000;
    background: #ffe6e6;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    border: 1px solid #ffcccc;
    font-size: 0.875rem;
    animation: fadeIn 0.2s ease;
    position: absolute;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.unit-select {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--white);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.unit-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.height-inches {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

.height-inches input {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.height-inches input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.calculate-btn {
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

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

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

.calculate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Result Styles */
.result {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease;
}

.result-content {
    text-align: center;
}

.bmi-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.bmi-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.bmi-unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.bmi-category {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    display: inline-block;
}

.bmi-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.health-range {
    font-size: 0.95rem;
    color: var(--text-light);
    font-style: italic;
}

/* BMI Category Colors */
.underweight {
    background: #e6f3ff;
    color: #0066cc;
}

.normal {
    background: #e8f5e8;
    color: #2d8630;
}

.overweight {
    background: #fff2e6;
    color: #cc7a00;
}

.obese {
    background: #ffe6e6;
    color: #cc0000;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Ad Containers */
.ad-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem 0;
}

.ad-container.ad-top {
    min-height: 90px;
    max-height: 250px;
    width: 100%;
    min-width: 320px;
}

.ad-container.ad-sidebar {
    min-height: 250px;
    max-height: 600px;
    width: 300px;
    min-width: 300px;
}

.ad-container.ad-bottom {
    min-height: 90px;
    max-height: 250px;
    width: 100%;
    min-width: 320px;
}

.ad-top {
    margin: 2rem 0;
    min-height: 120px;
}

.ad-sidebar {
    min-height: 600px;
    position: sticky;
    top: 2rem;
}

.ad-bottom {
    margin: 3rem 0;
    min-height: 120px;
}

.ad-placeholder {
    width: 100%;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.9rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px dashed #dee2e6;
    position: relative;
}

.ad-placeholder .adsbygoogle {
    width: 100% !important;
    height: auto !important;
    min-height: 90px;
}

/* Info Section */
.info-section {
    margin: 4rem 0;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.info-card {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.info-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

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

.info-card p {
    color: var(--text-secondary);
    line-height: 1.7;
}

.info-card ul {
    list-style: none;
    color: var(--text-secondary);
    line-height: 1.8;
}

.info-card ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.info-card ul li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 600;
}

.bmi-categories {
    list-style: none;
}

.bmi-categories li {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bmi-categories li::before {
    display: none;
}

.category {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--white);
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

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

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

.footer-section p {
    color: #cbd5e0;
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #cbd5e0;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: var(--accent-color);
}

.footer-bottom {
    border-top: 1px solid #4a5568;
    padding-top: 2rem;
    text-align: center;
}

.footer-bottom p {
    color: #a0aec0;
    font-size: 0.9rem;
    line-height: 1.6;
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 100px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .ad-sidebar {
        position: static;
        min-height: 250px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .hero h1 {
        font-size: 2.25rem;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .calculator-card {
        padding: 1.5rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .bmi-categories li {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.875rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .calculator-card {
        padding: 1rem;
    }
    
    .input-wrapper {
        flex-direction: column;
    }
    
    .unit-select {
        min-width: auto;
    }
    
    .bmi-number {
        font-size: 2.5rem;
    }
    
    .info-card {
        padding: 1.5rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .ad-container {
        display: none;
    }
    
    .main {
        padding: 0;
    }
    
    .calculator-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-light: #000;
        --text-secondary: #000;
    }
    
    .input-wrapper input,
    .unit-select,
    .height-inches input {
        border-width: 3px;
    }
}

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