* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --light-bg: #f7fafc;
    --dark-bg: #1a202c;
    --text-color: #2d3748;
    --border-color: #e2e8f0;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-color);
}

.container {
    width: 100%;
    max-width: 1200px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.logo-section h1 {
    font-size: 28px;
    font-weight: 700;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid transparent;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    border-color: white;
}

/* Tab Content */
.tab-content {
    padding: 40px;
    min-height: 500px;
}

.tab {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Calculator */
.calculator-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.calculator {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 100%;
}

.display-section {
    margin-bottom: 20px;
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
}

.display {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 32px;
    font-weight: 600;
    color: var(--text-color);
    text-align: right;
    margin-bottom: 8px;
    outline: none;
}

.expression {
    font-size: 14px;
    color: #718096;
    text-align: right;
    min-height: 20px;
}

/* Button Grid */
.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.btn {
    padding: 18px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: scale(0.95);
}

.number-btn {
    background: white;
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.number-btn:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.2);
}

.zero-btn {
    grid-column: span 2;
}

.operator-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 20px;
}

.operator-btn:hover {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.function-btn {
    background: #fbbf24;
    color: white;
    font-size: 16px;
}

.function-btn:hover {
    background: #f59e0b;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}

.equals-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    font-size: 20px;
}

.equals-btn:hover {
    box-shadow: 0 6px 16px rgba(72, 187, 120, 0.4);
}

/* Scientific Functions */
.scientific-functions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.sci-btn {
    background: #e2e8f0;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    font-size: 16px;
}

.sci-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

/* Converter */
.converter-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.converter-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow);
}

.converter-container h2 {
    margin-bottom: 25px;
    color: var(--text-color);
    text-align: center;
    font-size: 24px;
}

.converter-group {
    margin-bottom: 20px;
}

.converter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

.converter-select,
.unit-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.converter-select:focus,
.unit-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.unit-input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#from-value,
#to-value {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

#from-value:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-convert {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.3);
}

.conversion-result {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--success-color);
    min-height: 24px;
    display: none;
}

.conversion-result.show {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* History */
.history-wrapper {
    display: flex;
    justify-content: center;
}

.history-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow);
}

.history-container h2 {
    margin-bottom: 20px;
    color: var(--text-color);
    text-align: center;
    font-size: 24px;
}

.btn-clear-history {
    width: 100%;
    padding: 12px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.btn-clear-history:hover {
    background: #e53e3e;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 101, 101, 0.3);
}

.history-list {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
}

.history-item {
    padding: 12px;
    background: var(--light-bg);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background: #e2e8f0;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-expression {
    font-size: 14px;
    color: #718096;
    margin-bottom: 4px;
}

.history-result {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.copy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--secondary-color);
}

.empty-history {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 20px;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer p {
    margin: 0;
}

.footer a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.footer a:hover {
    text-decoration: underline;
    color: white;
}

/* Scrollbar Styling */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--light-bg);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 20px;
        flex-direction: column;
        gap: 15px;
    }

    .logo-section h1 {
        font-size: 22px;
    }

    .tab-content {
        padding: 20px;
        min-height: 400px;
    }

    .calculator {
        padding: 20px;
    }

    .button-grid {
        gap: 10px;
    }

    .btn {
        padding: 14px;
        font-size: 16px;
    }

    .display {
        font-size: 24px;
    }

    .converter-container,
    .history-container {
        padding: 20px;
    }

    .unit-input-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        border-radius: 15px;
    }

    .header {
        padding: 15px;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .logo-section h1 {
        font-size: 18px;
    }

    .nav-tabs {
        gap: 8px;
    }

    .tab-btn {
        padding: 8px 15px;
        font-size: 12px;
    }

    .tab-content {
        padding: 15px;
        min-height: auto;
    }

    .calculator {
        padding: 15px;
    }

    .button-grid {
        gap: 8px;
    }

    .btn {
        padding: 12px;
        font-size: 14px;
    }

    .display {
        font-size: 20px;
    }

    .expression {
        font-size: 12px;
    }

    .converter-container,
    .history-container {
        padding: 15px;
    }

    .converter-container h2,
    .history-container h2 {
        font-size: 20px;
    }
}
