/* ===== RESET & VARIABLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 30px -10px rgba(0, 0, 0, 0.15);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #374151;
}

/* ===== BASE STYLES ===== */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.app-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.app-header {
    margin-bottom: var(--spacing-lg);
}

.header-content {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.logo-text h1 {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text p {
    font-size: clamp(0.8rem, 3vw, 0.9rem);
    color: var(--text-secondary);
}

.theme-toggle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s;
}

.theme-toggle:hover {
    transform: rotate(15deg);
}

.theme-toggle i {
    font-size: 1.2rem;
    color: var(--text-primary);
}

/* ===== MAIN CONTAINER ===== */
.container {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex: 1;
}

/* ===== CALCULATOR CARD ===== */
.calculator-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: clamp(1rem, 4vw, 2rem);
    box-shadow: var(--shadow);
}

/* Period section */
.period-section {
    margin-bottom: var(--spacing-lg);
}

.section-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.period-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
}

.period-btn {
    padding: clamp(0.8rem, 3vw, 1rem);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: clamp(0.9rem, 3vw, 1rem);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.period-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

/* Calc sections */
.calc-section {
    display: none;
}

.calc-section.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Input groups */
.input-group {
    margin-bottom: var(--spacing-md);
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: clamp(0.9rem, 3vw, 1rem);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.calc-input {
    width: 100%;
    padding: clamp(0.8rem, 3vw, 1rem);
    padding-right: 60px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: clamp(1rem, 3vw, 1.1rem);
    background: var(--bg-color);
    color: var(--text-primary);
    transition: all 0.3s;
}

.calc-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-unit {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Action buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-sm);
    margin: var(--spacing-lg) 0;
}

.btn {
    padding: clamp(0.8rem, 3vw, 1.2rem);
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: clamp(0.9rem, 3vw, 1rem);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Result card */
.result-card {
    padding: clamp(1rem, 4vw, 1.5rem);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    text-align: center;
    transition: all 0.3s;
}

.result-default {
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
}

.result-excellent {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
    border: 2px solid var(--success-color);
}

.result-good {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.2));
    border: 2px solid var(--warning-color);
}

.result-average {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2));
    border: 2px solid var(--danger-color);
}

.result-poor {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.1), rgba(107, 114, 128, 0.2));
    border: 2px solid var(--text-muted);
}

.result-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
}

.result-placeholder i {
    font-size: 2rem;
}

.result-placeholder div {
    display: flex;
    flex-direction: column;
}

.result-placeholder span {
    font-size: 1.2rem;
    font-weight: 600;
}

.result-placeholder small {
    font-size: 0.85rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.stat-item {
    background: var(--bg-color);
    padding: clamp(0.8rem, 3vw, 1rem);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.stat-item div {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== INFO PANEL ===== */
.info-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.info-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: clamp(1rem, 3vw, 1.5rem);
    box-shadow: var(--shadow);
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: var(--spacing-md);
}

.info-card-header i {
    font-size: 1.2rem;
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.info-card-header h3 {
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 600;
}

/* Grade scale */
.grade-scale {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.grade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border-radius: var(--radius-md);
    font-size: clamp(0.9rem, 3vw, 1rem);
}

.grade-item.excellent {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.grade-item.good {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.grade-item.average {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.grade-item.poor {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
}

.grade-range {
    font-weight: 600;
}

.grade-badge {
    padding: 0.3rem 0.8rem;
    background: var(--bg-color);
    border-radius: 2rem;
    font-size: 0.85rem;
}

/* Tips list */
.tips-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.tip-item {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    transition: transform 0.3s;
}

.tip-item:hover {
    transform: translateX(5px);
}

.tip-icon {
    flex-shrink: 0;
    width: 35px;
    height: 35px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
}

.tip-content strong {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

.tip-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* News items */
.news-item {
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.news-item:last-child {
    border-bottom: none;
}

.news-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.news-item p {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Author card */
.author-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-xl);
    padding: var(--spacing-md);
    color: white;
}

.author-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.author-info i {
    font-size: 2rem;
}

.author-info strong {
    font-size: 1.1rem;
}

.author-contact {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.author-contact i {
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s;
}

.author-contact i:hover {
    transform: scale(1.2);
}

/* ===== FOOTER ===== */
.app-footer {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-size: clamp(0.8rem, 3vw, 0.9rem);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.app-footer p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-small {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.fa-heart {
    color: #ef4444;
    animation: heartbeat 1.5s ease infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== BACK TO TOP ===== */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 100;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
}

/* ===== RESPONSIVE DESIGN ===== */
/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .info-panel {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .author-card {
        grid-column: span 2;
    }
}

/* Mobile landscape (576px - 768px) */
@media (max-width: 768px) {
    .app-wrapper {
        padding: 0.5rem;
    }
    
    .header-content {
        padding: var(--spacing-sm);
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-item {
        justify-content: center;
    }
    
    .info-panel {
        grid-template-columns: 1fr;
    }
    
    .author-card {
        grid-column: span 1;
    }
    
    .tip-item {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
    
    .tip-icon {
        margin-bottom: 0.5rem;
    }
}

/* Mobile portrait (320px - 576px) */
@media (max-width: 576px) {
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .period-grid {
        grid-template-columns: 1fr;
    }
    
    .result-placeholder {
        flex-direction: column;
        text-align: center;
    }
    
    .grade-item {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .grade-badge {
        width: 100%;
    }
    
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Small phones (320px dan kichik) */
@media (max-width: 320px) {
    .logo-area {
        flex-direction: column;
        text-align: center;
    }
    
    .logo-text h1 {
        font-size: 1.1rem;
    }
    
    .logo-text p {
        font-size: 0.8rem;
    }
    
    .input-wrapper {
        flex-direction: column;
    }
    
    .input-unit {
        position: static;
        margin-top: 0.3rem;
    }
    
    .calc-input {
        padding-right: 1rem;
    }
}

/* Yuksek DPI qurilmalar uchun */
@media (min-width: 1400px) {
    .app-wrapper {
        max-width: 1600px;
    }
    
    html {
        font-size: 18px;
    }
}

/* Print styles */
@media print {
    .theme-toggle,
    .back-to-top,
    .btn {
        display: none !important;
    }
    
    .calculator-card,
    .info-card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .tip-item:hover,
    .period-btn:hover {
        transform: none;
    }
    
    .btn:active,
    .period-btn:active {
        transform: scale(0.98);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --primary-gradient: linear-gradient(135deg, #0000ff, #800080);
    }
    
    .btn-primary {
        border: 2px solid #000;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .app-header {
        margin-bottom: var(--spacing-sm);
    }
    
    .container {
        gap: var(--spacing-sm);
    }
    
    .calculator-card {
        padding: var(--spacing-sm);
    }
}
