/* ====================================
   Mole Calculator Styles
   Created: 2025-01-13
   Description: Chemistry-specific styling for mole calculator with 5 modes
   ==================================== */

/* ====================================
   Mode Selector Tabs
   ==================================== */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.mode-tab {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #667eea;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
}

.mode-tab:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.mode-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: white;
    color:white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.mode-tab i {
    margin-right: 0.5rem;
}

/* ====================================
   Input Panel Sections
   ==================================== */
.input-section {
    display: none;
}

.input-section.active {
    display: block;
}

.form-group {
    margin-bottom: 1.25rem;
}

/* Two inputs per row grid */
.form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-row-grid .form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label i.fa-info-circle {
    font-size: 0.9rem;
    color: #667eea;
    cursor: help;
}


.form-input.error {
    border-color: #f56565;
}

.form-select option {
    background: #2d3748;
    color: white;
}

/* Unit Selector Group */
.input-with-unit {
    display: flex;
    gap: 0.5rem;
}

.input-with-unit .form-input {
    flex: 2;
}

.input-with-unit .form-select {
    flex: 1;
    min-width: 100px;
}

/* ====================================
   Preset Buttons (STP/SATP)
   ==================================== */
.preset-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-preset {
    flex: 1;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 6px;
    color: #667eea;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-preset:hover {
    background: #f0f4ff;
    transform: translateY(-1px);
    border-color: #667eea;
}

.btn-preset i {
    margin-right: 0.3rem;
}

/* ====================================
   Results Panel
   ==================================== */
.result-item {
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.result-label {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.result-value .unit {
    font-size: 1rem;
    font-weight: 500;
    color: #4a5568;
}

.result-scientific {
    font-family: 'Courier New', monospace;
    background: #e2e8f0;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 1.2rem;
    color: #2d3748;
}

/* ====================================
   Formula Display (KaTeX)
   ==================================== */
.formula-display {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.formula-display .katex {
    font-size: 1.4rem;
    color: #2d3748;
}

.formula-display .katex-display {
    margin: 0.5rem 0;
}

/* ====================================
   Calculation Steps
   ==================================== */
.steps-container {
    margin-top: 1.5rem;
}

.toggle-steps {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.toggle-steps:hover {
    background: #f0f4ff;
}

.toggle-steps i {
    transition: transform 0.3s ease;
}

.toggle-steps.collapsed i {
    transform: rotate(-180deg);
}

.steps-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.steps-content.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculation-step {
    background: white;
    border-left: 4px solid #667eea;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.step-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

.step-description {
    flex: 1;
    color: #2d3748;
    font-weight: 500;
}

.step-formula {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 6px;
    margin: 0.75rem 0;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.step-formula .katex {
    color: #2d3748;
    font-size: 1.2rem;
}

.step-result {
    color: #2d3748;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem;
    background: #c6f6d5;
    border-radius: 4px;
    border-left: 3px solid #48bb78;
}

/* ====================================
   Chart Container
   ==================================== */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1.5rem 0;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* ====================================
   Action Buttons Grid
   ==================================== */
.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Action Buttons */
.btn-custom,
.btn-custom-outline {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.btn-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-custom-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-custom-outline:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8edff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.btn-custom:active,
.btn-custom-outline:active {
    transform: translateY(0);
}

/* Sponsor Button */
.btn-sponsor {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.btn-sponsor:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-sponsor:active {
    transform: translateY(0);
}

/* ====================================
   Common Substances Database
   ==================================== */
.substance-selector {
    margin-bottom: 1rem;
}

.substance-quick-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-substance {
    padding: 0.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #2d3748;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-substance:hover {
    background: #f0f4ff;
    border-color: #667eea;
}

.btn-substance .formula {
    font-weight: 700;
    display: block;
    margin-bottom: 0.25rem;
    color: #667eea;
}

.btn-substance .name {
    font-size: 0.75rem;
    color: #718096;
}

/* ====================================
   Error Messages
   ==================================== */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid #f56565;
    margin-bottom: 1rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

.error-message.show {
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.error-message i {
    font-size: 1.2rem;
}

/* ====================================
   Tooltips
   ==================================== */
.tooltip-trigger {
    cursor: help;
    position: relative;
}

.custom-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-bottom: 0.5rem;
}

.tooltip-trigger:hover .custom-tooltip {
    opacity: 1;
}

.custom-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ====================================
   Responsive Design
   ==================================== */

/* Tablet */
@media (max-width: 991px) {
    .mode-selector {
        grid-template-columns: repeat(3, 1fr);
    }

    .substance-quick-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-value {
        font-size: 1.3rem;
    }

    .chart-container {
        height: 250px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .mode-selector {
        flex-direction: column;
    }

    .mode-tab {
        min-width: 100%;
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }

    .action-buttons-grid {
        grid-template-columns: 1fr;
    }

    .form-row-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-row-grid .form-group {
        margin-bottom: 1.25rem;
    }

    .input-with-unit {
        flex-direction: column;
    }

    .input-with-unit .form-select {
        width: 100%;
    }

    .preset-buttons {
        flex-direction: column;
    }

    .substance-quick-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-value {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-container {
        height: 200px;
    }

    .step-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .seo-section {
        padding: 1.5rem;
    }

    .seo-section h2 {
        font-size: 1.5rem;
    }

    .seo-section h3 {
        font-size: 1.2rem;
    }

    .custom-tooltip {
        white-space: normal;
        max-width: 200px;
    }
}

/* Very Small Mobile */
@media (max-width: 375px) {
    .formula-display .katex {
        font-size: 1.1rem;
    }

    .step-formula .katex {
        font-size: 1rem;
    }
}

/* ====================================
   Print Styles (for PDF Export)
   ==================================== */
@media print {
    .action-buttons-grid,
    .toggle-steps,
    .btn-preset {
        display: none !important;
    }

    .steps-content {
        display: block !important;
    }

    .glass-card {
        page-break-inside: avoid;
    }

    .calculation-step {
        page-break-inside: avoid;
    }
}
