/* Molar Mass Calculator - Component Styles */

:root {
    --mm-tool: #059669;
    --mm-tool-dark: #047857;
    --mm-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --mm-light: rgba(5, 150, 105, 0.08);
    --mm-tool-rgb: 5, 150, 105;
}
[data-theme="dark"] {
    --mm-light: rgba(5, 150, 105, 0.15);
}

/* ===== Output Tabs ===== */
.mm-output-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 0.75rem 0.75rem 0 0;
    overflow: hidden;
}
.mm-output-tab {
    flex: 1;
    padding: 0.625rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
    font-family: var(--font-sans);
    text-align: center;
    position: relative;
}
.mm-output-tab.active {
    color: var(--mm-tool);
    background: var(--bg-primary);
}
.mm-output-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--mm-tool);
}
.mm-output-tab:hover:not(.active) {
    background: var(--bg-tertiary);
}

/* ===== Panels ===== */
.mm-panel { display: none; }
.mm-panel.active { display: block; }

/* ===== Input Groups ===== */
.mm-input-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.mm-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    font-family: var(--font-mono);
    border: 1.5px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: left;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.mm-input:focus {
    outline: none;
    border-color: var(--mm-tool);
    box-shadow: 0 0 0 2px rgba(var(--mm-tool-rgb), 0.1);
}
.mm-input-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ===== Formula Preview ===== */
.mm-formula-preview {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    min-height: 1.5rem;
    font-family: var(--font-mono);
    text-align: center;
}
.mm-formula-preview:empty { display: none; }
.mm-formula-preview sub { font-size: 0.7em; }

/* ===== Example Chips ===== */
.mm-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.mm-example-chip {
    padding: 0.3rem 0.625rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.mm-example-chip:hover {
    border-color: var(--mm-tool);
    color: var(--mm-tool);
    background: var(--mm-light);
}

/* ===== Result Display ===== */
.mm-mass-card {
    text-align: center;
    padding: 1.25rem;
    background: var(--mm-gradient);
    border-radius: 0.75rem;
    color: #fff;
    margin-bottom: 0.75rem;
}
.mm-mass-label {
    font-size: 0.8125rem;
    opacity: 0.9;
}
.mm-mass-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.25rem 0;
    line-height: 1.2;
}
.mm-mass-unit {
    font-size: 0.9375rem;
    opacity: 0.85;
}
.mm-compound-name {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}
.mm-formula-display {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    margin-top: 0.375rem;
}
.mm-formula-display sub { font-size: 0.7em; }

/* ===== Composition Table ===== */
.mm-comp-table-wrap {
    overflow-x: auto;
    margin: 0.75rem 0;
}
.mm-comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.mm-comp-table th {
    padding: 0.375rem 0.5rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
}
.mm-comp-table td {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.mm-comp-table tr { transition: background 0.1s; }
.mm-comp-table tbody tr:hover { background: var(--mm-light); }
.mm-elem-sym {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--mm-tool);
}
.mm-elem-name {
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.mm-pct-bar {
    width: 100%;
    height: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    min-width: 60px;
}
.mm-pct-fill {
    height: 100%;
    background: var(--mm-gradient);
    border-radius: 8px;
    transition: width 0.3s;
}

/* ===== Action Buttons ===== */
.mm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}
.mm-action-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-sans);
}
.mm-action-btn:hover {
    border-color: var(--mm-tool);
    color: var(--mm-tool);
}
.mm-action-btn.mm-copied {
    border-color: #059669;
    color: #059669;
}

/* ===== Periodic Table ===== */
.mm-ptable-grid {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 2px;
    margin-bottom: 1rem;
    overflow-x: auto;
}
.mm-ptable-cell {
    aspect-ratio: 1;
    min-width: 38px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.7rem;
    padding: 1px;
}
.mm-ptable-cell:hover {
    transform: scale(1.12);
    border-color: var(--mm-tool);
    box-shadow: 0 2px 8px rgba(var(--mm-tool-rgb), 0.25);
    z-index: 10;
}
.mm-ptable-cell.selected {
    background: var(--mm-gradient);
    color: #fff;
    border-color: var(--mm-tool);
}
.mm-ptable-cell.selected .mm-ptable-num,
.mm-ptable-cell.selected .mm-ptable-mass { opacity: 0.9; }
.mm-ptable-num { font-size: 0.55rem; opacity: 0.6; line-height: 1; }
.mm-ptable-sym { font-size: 0.875rem; font-weight: 700; line-height: 1.2; }
.mm-ptable-mass { font-size: 0.55rem; opacity: 0.6; line-height: 1; }
.mm-ptable-placeholder {
    background: transparent;
    border: none;
    cursor: default;
}
.mm-ptable-placeholder:hover {
    transform: none;
    box-shadow: none;
}

/* Element category colors */
.mm-cat-nonmetal { background: #e0f2fe; }
.mm-cat-noble-gas { background: #fce7f3; }
.mm-cat-alkali-metal { background: #fff7ed; }
.mm-cat-alkaline-earth { background: #fef3c7; }
.mm-cat-transition-metal { background: #fef2f2; }
.mm-cat-post-transition { background: #f3f4f6; }
.mm-cat-metalloid { background: #e7e5e4; }
.mm-cat-halogen { background: #dbeafe; }
.mm-cat-lanthanide { background: #fae8ff; }
.mm-cat-actinide { background: #fce7f3; }

[data-theme="dark"] .mm-cat-nonmetal { background: rgba(56, 189, 248, 0.12); }
[data-theme="dark"] .mm-cat-noble-gas { background: rgba(236, 72, 153, 0.12); }
[data-theme="dark"] .mm-cat-alkali-metal { background: rgba(251, 146, 60, 0.12); }
[data-theme="dark"] .mm-cat-alkaline-earth { background: rgba(250, 204, 21, 0.12); }
[data-theme="dark"] .mm-cat-transition-metal { background: rgba(248, 113, 113, 0.10); }
[data-theme="dark"] .mm-cat-post-transition { background: rgba(156, 163, 175, 0.12); }
[data-theme="dark"] .mm-cat-metalloid { background: rgba(168, 162, 158, 0.12); }
[data-theme="dark"] .mm-cat-halogen { background: rgba(96, 165, 250, 0.12); }
[data-theme="dark"] .mm-cat-lanthanide { background: rgba(192, 132, 252, 0.12); }
[data-theme="dark"] .mm-cat-actinide { background: rgba(244, 114, 182, 0.12); }

/* ===== Selected Elements ===== */
.mm-selected-elements {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.mm-sel-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.5rem;
    border: 1.5px solid var(--mm-tool);
    border-radius: 0.375rem;
    background: var(--mm-light);
    font-size: 0.8125rem;
}
.mm-sel-sym {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--mm-tool);
}
.mm-sel-count {
    width: 2.5rem;
    padding: 0.15rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
}
.mm-sel-del {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0;
    line-height: 1;
}
.mm-sel-del:hover { color: #ef4444; }

/* ===== Category Legend ===== */
.mm-ptable-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.6875rem;
}
.mm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.mm-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid var(--border);
}

/* ===== Compounds Panel ===== */
.mm-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border: 1.5px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}
.mm-search-input:focus {
    outline: none;
    border-color: var(--mm-tool);
}
.mm-compounds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}
.mm-compound-card {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.mm-compound-card:hover {
    border-color: var(--mm-tool);
    background: var(--mm-light);
    transform: translateY(-1px);
}
.mm-compound-formula {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}
.mm-compound-formula sub { font-size: 0.7em; }
.mm-compound-name {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.mm-cat-header {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-top: 0.5rem;
}
.mm-cat-header:first-child { margin-top: 0; }

/* ===== Learn Panel ===== */
.mm-learn-section {
    padding: 0.75rem;
}
.mm-learn-section h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
}
.mm-learn-section h4:first-child { margin-top: 0; }
.mm-learn-section p,
.mm-learn-section li {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.mm-learn-section ol, .mm-learn-section ul {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}
.mm-learn-callout {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: var(--mm-light);
    border: 1px solid rgba(var(--mm-tool-rgb), 0.15);
    margin: 0.75rem 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== History ===== */
.mm-history {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.mm-history-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}
.mm-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.mm-history-item {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.375rem;
    border-radius: 0.25rem;
    transition: all 0.1s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mm-history-item:hover {
    background: var(--mm-light);
    color: var(--mm-tool);
}
.mm-history-item-mass {
    font-weight: 600;
    color: var(--mm-tool);
    font-size: 0.6875rem;
}
.mm-history-clear {
    font-size: 0.6875rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
    font-family: var(--font-sans);
}
.mm-history-clear:hover { color: var(--mm-tool); }

/* ===== Educational Section Numbers ===== */
.mm-section-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--mm-gradient);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* ===== Step Cards ===== */
.mm-steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.mm-step-card {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    text-align: center;
}
.mm-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--mm-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}
.mm-step-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.375rem;
    color: var(--text-primary);
}
.mm-step-card p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ===== Callout ===== */
.mm-callout {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}
.mm-callout-insight {
    background: rgba(var(--mm-tool-rgb), 0.06);
    border: 1px solid rgba(var(--mm-tool-rgb), 0.15);
}
.mm-callout-icon { font-size: 1.25rem; flex-shrink: 0; }
.mm-callout-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== FAQ ===== */
.mm-faq-item {
    border-bottom: 1px solid var(--border);
}
.mm-faq-item:last-child { border-bottom: none; }
.mm-faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    gap: 0.5rem;
    font-family: var(--font-sans);
}
.mm-faq-question:hover { color: var(--mm-tool); }
.mm-faq-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.mm-faq-item.open .mm-faq-chevron { transform: rotate(180deg); }
.mm-faq-answer {
    display: none;
    padding: 0 0 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.7;
}
.mm-faq-item.open .mm-faq-answer { display: block; }

/* ===== Scroll Animations ===== */
.mm-anim {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.mm-anim.mm-visible {
    opacity: 1;
    transform: translateY(0);
}
.mm-anim-d1 { transition-delay: 0.05s; }
.mm-anim-d2 { transition-delay: 0.1s; }
.mm-anim-d3 { transition-delay: 0.15s; }
.mm-anim-d4 { transition-delay: 0.2s; }

/* ===== Alert ===== */
.mm-alert {
    padding: 0.625rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.mm-alert-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #991b1b;
}
.mm-alert-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #1e40af;
}
[data-theme="dark"] .mm-alert-error { color: #fca5a5; }
[data-theme="dark"] .mm-alert-info { color: #60a5fa; }

/* ===== Example Calculation ===== */
.mm-example-calc {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.8125rem;
}
.mm-example-calc code {
    font-family: var(--font-mono);
    color: var(--mm-tool);
    font-weight: 600;
}

/* ===== Print Styles ===== */
@media print {
    .mm-output-tabs,
    .mm-actions,
    .mm-history,
    .tool-input-column,
    .tool-ads-column { display: none !important; }
    .mm-panel { display: block !important; }
    .mm-panel:not(#mm-panel-result) { display: none !important; }
    #mm-panel-result { display: block !important; }
    .mm-mass-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .mm-ptable-grid {
        grid-template-columns: repeat(9, 1fr);
        gap: 1px;
    }
    .mm-ptable-cell {
        min-width: 30px;
        font-size: 0.6rem;
    }
    .mm-ptable-sym { font-size: 0.75rem; }
    .mm-ptable-num, .mm-ptable-mass { font-size: 0.45rem; }
    .mm-mass-value { font-size: 2rem; }
    .mm-compounds-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}
