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

:root {
    --primary-blue: #1976D2;
    --primary-blue-dark: #1565C0;
    --secondary-orange: #FF5722;
    --charcoal: #424242;
    --light-gray: #F5F7FA;
    --border-gray: #E0E0E0;
    --text-gray: #666;
    --success-green: #4CAF50;
    --error-red: #F44336;
    --white: #FFFFFF;
    --black: #000000;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    color: var(--charcoal);
    background-color: var(--light-gray);
}

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

/* Header */
.header {
    background: var(--white);
    border-bottom: 3px solid var(--primary-blue);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 2rem;
    color: var(--primary-blue);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--charcoal);
}

.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-gray);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-blue);
    background-color: rgba(25, 118, 210, 0.1);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-gray);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-gray);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    color: var(--white);
    padding: 4rem 0;
    text-align: center;
}

.hero-content h2 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.search-bar {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.search-bar input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    outline: none;
    font-size: 1rem;
}

.search-btn {
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-btn:hover {
    background: var(--primary-blue-dark);
}

/* Categories Section */
.categories {
    padding: 4rem 0;
}

.categories h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--charcoal);
}

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

.category-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.category-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-blue);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.category-icon i {
    font-size: 1.8rem;
    color: var(--white);
}

.category-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--charcoal);
}

.category-card p {
    color: var(--text-gray);
    margin-bottom: 1.5rem;
}

.calculator-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calc-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--light-gray);
    border-radius: 8px;
    text-decoration: none;
    color: var(--charcoal);
    transition: all 0.3s ease;
}

.calc-link:hover {
    background: var(--primary-blue);
    color: var(--white);
    transform: translateX(5px);
}

.calc-link i {
    color: var(--primary-blue);
    transition: color 0.3s ease;
}

.calc-link:hover i {
    color: var(--white);
}

/* Features Section */
.features {
    background: var(--white);
    padding: 4rem 0;
}

.features h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--charcoal);
}

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

.feature {
    text-align: center;
    padding: 2rem;
}

.feature i {
    font-size: 3rem;
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

.feature h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--charcoal);
}

.feature p {
    color: var(--text-gray);
}

/* FAQ Section */
.faq {
    padding: 4rem 0;
}

.faq h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--charcoal);
}

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

.faq-item {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.faq-item h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--charcoal);
}

.faq-item p {
    color: var(--text-gray);
}

/* Footer */
.footer {
    background: var(--charcoal);
    color: var(--white);
    padding: 3rem 0 1rem;
}

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

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
}

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

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

.footer-section ul li a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 1rem;
    text-align: center;
    color: rgba(255,255,255,0.8);
}

/* Calculator Page Styles */
.calculator-header {
    background: var(--white);
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-gray);
}

.calculator-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.calculator-title i {
    font-size: 2rem;
    color: var(--primary-blue);
}

.calculator-title h1 {
    font-size: 2.5rem;
    color: var(--charcoal);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--primary-blue);
    text-decoration: none;
}

.calculator-content {
    padding: 3rem 0;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.input-panel,
.result-panel {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: var(--charcoal);
}

.panel-title i {
    color: var(--primary-blue);
}

.formula-display {
    background: rgba(25, 118, 210, 0.1);
    border-left: 4px solid var(--primary-blue);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.formula-display .formula-name {
    font-weight: 600;
    color: var(--charcoal);
    margin-bottom: 0.5rem;
}

.formula-display .formula-equation {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.2rem;
    color: var(--charcoal);
    margin-bottom: 0.5rem;
}

.formula-display .formula-description {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--charcoal);
}

.input-row {
    display: flex;
    gap: 0.75rem;
}

.input-field {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-gray);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.unit-select {
    width: 100px;
    padding: 0.75rem;
    border: 2px solid var(--border-gray);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
}

.calculate-btn {
    width: 100%;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 1rem;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-bottom: 1rem;
}

.calculate-btn:hover {
    background: var(--primary-blue-dark);
}

.clear-btn {
    width: 100%;
    background: transparent;
    color: var(--text-gray);
    border: 2px solid var(--border-gray);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.result-display {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid var(--success-green);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--success-green);
    margin-bottom: 1rem;
}

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

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

.result-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-green);
}

.result-label {
    font-size: 0.9rem;
    color: var(--text-gray);
    text-transform: capitalize;
}

.steps-section {
    border-top: 2px solid var(--border-gray);
    padding-top: 1.5rem;
}

.steps-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--charcoal);
    margin-bottom: 1rem;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content .step-description {
    font-weight: 500;
    color: var(--charcoal);
    margin-bottom: 0.25rem;
}

.step-content .step-formula,
.step-content .step-calculation {
    font-family: 'Roboto Mono', monospace;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-gray);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.error-message {
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid var(--error-red);
    color: var(--error-red);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-content h2 {
        font-size: 2rem;
    }
    
    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        gap: 1rem;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .input-row {
        flex-direction: column;
    }
    
    .unit-select {
        width: 100%;
    }
}

/* Loading Indicators and Animations */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 100;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-gray);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-text {
    color: var(--primary-blue);
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.loading-subtext {
    color: var(--text-gray);
    font-size: 0.9rem;
    text-align: center;
    max-width: 200px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button loading animation */
.calculate-btn.loading {
    animation: pulse 1.5s ease-in-out infinite;
    pointer-events: none;
    position: relative;
}

.calculate-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(25, 118, 210, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 6px 25px rgba(25, 118, 210, 0.5);
    }
}

/* Progress bar animation */
.calculation-progress {
    width: 100%;
    height: 4px;
    background: var(--light-gray);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-blue-dark));
    border-radius: 2px;
    animation: progress 2s ease-in-out;
    transform-origin: left;
}

@keyframes progress {
    0% {
        transform: scaleX(0);
    }
    50% {
        transform: scaleX(0.7);
    }
    100% {
        transform: scaleX(1);
    }
}

/* Calculation steps fade-in animation */
.step-item {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease forwards;
}

.step-item:nth-child(1) { animation-delay: 0.1s; }
.step-item:nth-child(2) { animation-delay: 0.2s; }
.step-item:nth-child(3) { animation-delay: 0.3s; }
.step-item:nth-child(4) { animation-delay: 0.4s; }
.step-item:nth-child(5) { animation-delay: 0.5s; }
.step-item:nth-child(6) { animation-delay: 0.6s; }
.step-item:nth-child(7) { animation-delay: 0.7s; }
.step-item:nth-child(8) { animation-delay: 0.8s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Result items animation */
.result-item {
    opacity: 0;
    transform: scale(0.95);
    animation: fadeInScale 0.4s ease forwards;
}

.result-item:nth-child(1) { animation-delay: 0.1s; }
.result-item:nth-child(2) { animation-delay: 0.15s; }
.result-item:nth-child(3) { animation-delay: 0.2s; }
.result-item:nth-child(4) { animation-delay: 0.25s; }
.result-item:nth-child(5) { animation-delay: 0.3s; }
.result-item:nth-child(6) { animation-delay: 0.35s; }

@keyframes fadeInScale {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading dots animation */
.loading-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Shimmer effect for loading placeholders */
.loading-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    height: 20px;
    margin: 0.5rem 0;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Success animation */
.result-display {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInSuccess 0.6s ease forwards;
}

@keyframes slideInSuccess {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error shake animation */
.error-message.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Relative positioning for loading overlay */
.result-panel {
    position: relative;
}

.input-panel {
    position: relative;
}

/* Success checkmark animation */
.success-checkmark {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--success-green);
    position: relative;
    margin-bottom: 1rem;
}

.success-checkmark::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 22px;
    width: 16px;
    height: 25px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    animation: checkmark 0.3s ease-in-out 0.3s forwards;
    opacity: 0;
}

@keyframes checkmark {
    to {
        opacity: 1;
    }
}

/* Floating calculation particles */
.calculation-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-blue);
    border-radius: 50%;
    animation: float 3s ease-in-out infinite;
    opacity: 0.6;
}

.calculation-particle:nth-child(1) { animation-delay: 0s; left: 10%; }
.calculation-particle:nth-child(2) { animation-delay: 0.5s; left: 30%; }
.calculation-particle:nth-child(3) { animation-delay: 1s; left: 50%; }
.calculation-particle:nth-child(4) { animation-delay: 1.5s; left: 70%; }
.calculation-particle:nth-child(5) { animation-delay: 2s; left: 90%; }

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-20px);
        opacity: 1;
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    body.dark-mode {
        --white: #1a1a1a;
        --light-gray: #121212;
        --charcoal: #ffffff;
        --text-gray: #cccccc;
        --border-gray: #333333;
    }
    
    .loading-overlay {
        background: rgba(26, 26, 26, 0.95);
    }
    
    .loading-placeholder {
        background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
        background-size: 200% 100%;
    }
}