/*
Theme Name: MathPro Suite
Theme URI: https://mathprosuite.com/
Author: Your Name
Author URI: https://mathprosuite.com/
Description: A custom theme for the MathPro Suite, an all-in-one online math toolkit with a scientific calculator, graphing tools, and AI-powered features.
Version: 1.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: calculator, math, education, custom-header, dark-theme
Text Domain: mathpro-suite
*/

/* --- CSS Variables and Base Styles --- */
:root {
    --bg-main: #1a1b26;
    --bg-surface: #24283b;
    --bg-panel: #1e2029;
    --text-primary: #c0caf5;
    --text-secondary: #a9b1d6;
    --accent-primary: #7aa2f7;
    --accent-secondary: #9ece6a;
    --accent-tertiary: #bb9af7;
    --border-color: #414868;
    --button-bg: #414868;
    --button-hover-bg: #565f89;
    --button-active-bg: #7aa2f7;
    --error-color: #f7768e;
    --success-color: #9ece6a;
    --font-family: 'Inter', sans-serif;
}

html {
    scroll-behavior: smooth;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
    font-size: 16px;
}

/* --- General Layout & Typography --- */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1, h2, h3, h4 {
    color: var(--accent-primary);
    font-weight: 700;
    margin-top: 0;
}

h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; color: var(--accent-secondary); }

a {
    color: var(--accent-tertiary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--text-primary);
}

p {
    margin-bottom: 1rem;
}

hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

/* --- Header & Footer --- */
.site-header, .site-footer {
    background-color: var(--bg-surface);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.main-site-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.footer-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 0;
}

.footer-bottom {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.footer-column ul { list-style: none; padding: 0; }
.footer-column ul li { margin-bottom: 0.5rem; }
.social-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.social-links a svg { width: 24px; height: 24px; fill: var(--text-secondary); transition: fill 0.2s; }
.social-links a:hover svg { fill: var(--accent-tertiary); }

/* --- Content Sections --- */
.content-section {
    background-color: var(--bg-surface);
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* --- Tool Navigator --- */
.tool-navigator {
    padding: 1rem;
    background-color: var(--bg-surface);
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}
.tool-navigator ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    background-color: var(--bg-panel);
    border-radius: 8px;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}
.tool-navigator a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}
.tool-navigator a:hover {
    background-color: var(--button-hover-bg);
    color: var(--text-primary);
}
.tool-navigator a.active {
    background-color: var(--button-active-bg);
    color: var(--bg-main);
    font-weight: 700;
}

/* --- Tool Panels --- */
 #tool-panels-container {
    max-width: 1200px;
    margin: 0 auto 2rem auto;
    padding: 0 1rem;
}
.tool-panel {
    display: none;
    background-color: var(--bg-panel);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.tool-panel.active {
    display: block;
}
.tool-panel h2 {
    margin-top: 0;
    border-bottom: 2px solid var(--accent-secondary);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* --- General Form Elements --- */
.form-group { margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
input[type="text"], input[type="number"], textarea, select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.3);
}
textarea {
    resize: vertical;
    min-height: 80px;
}
.tool-button, .gemini-button {
    background-color: var(--button-bg);
    color: var(--text-primary);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: background-color 0.2s;
    margin-top: 0.5rem;
}
.tool-button:hover, .gemini-button:hover {
    background-color: var(--button-hover-bg);
}
.gemini-button {
    background-color: var(--accent-tertiary);
    color: var(--bg-main);
}
.gemini-button:hover {
    background-color: #ff9e64;
}
.gemini-button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}
.result-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-surface);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    min-height: 50px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', Courier, monospace;
    color: var(--success-color);
}
.gemini-result-box {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-surface);
    border-radius: 8px;
    border: 1px solid var(--accent-tertiary);
    color: var(--text-primary);
    font-family: var(--font-family);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.gemini-result-box h4 { color: var(--accent-secondary); }
.gemini-result-box ul { padding-left: 20px; }
.gemini-result-box code {
    background-color: var(--bg-panel);
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
}
 .gemini-result-box pre > code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
}
.tool-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* --- New Scientific Calculator Style --- */
#scientific-panel {
    background: #243b55;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}
#scientific-panel #display {
    background: #1b2a41;
    font-size: 2rem;
    font-weight: 700;
    padding: 1rem 1.3rem;
    border-radius: 12px;
    color: #a6e22e;
    min-height: 60px;
    overflow-x: auto;
    white-space: nowrap;
    text-align: right;
}
#scientific-panel #result {
    background: #0f172a;
    margin-top: 0.5rem;
    padding: 0.7rem 1.3rem;
    font-size: 1.3rem;
    border-radius: 12px;
    color: #f8f8f2;
    min-height: 40px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    text-align: right;
}
#scientific-panel .buttons {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-gap: 10px;
}
#scientific-panel .buttons button {
    background: #3a4a6d;
    border: none;
    border-radius: 10px;
    color: #dcdcdc;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.8rem;
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.1s ease;
    user-select: none;
    position: relative;
}
#scientific-panel .buttons button:hover { background-color: #556a9e; }
#scientific-panel .buttons button:active { transform: scale(0.95); }
#scientific-panel .buttons button.operator { background: #6a82b7; color: #fff; }
#scientific-panel .buttons button.function { background: #5078a0; }
#scientific-panel .buttons button.control { background: #a83232; color: #fff; }
#scientific-panel .buttons button.toggle-active { background: #c99a38; }
#scientific-panel .buttons button.zero { grid-column: span 2; }
#scientific-panel .buttons #equals { grid-column: span 2; }


/* --- Graphing Calculator --- */
#graph-container {
    width: 100%;
    height: 450px;
    background: var(--bg-surface);
}

/* --- Matrix Calculator --- */
.matrix-ops {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* --- AI Math Assistant --- */
#ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
#ai-chat-history {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.5;
}
.ai-message {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    align-self: flex-start;
}
.user-message {
    background-color: var(--accent-primary);
    color: var(--bg-main);
    align-self: flex-end;
}
.loading-message, .gemini-loading {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}
.loading-dot {
    width: 8px; height: 8px; background-color: var(--text-secondary); border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}
#ai-input-container {
    display: flex;
    padding: 0.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}
#ai-prompt-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    resize: none;
    font-size: 1rem;
    color: var(--text-primary);
    max-height: 100px;
}
#ai-prompt-input:focus {
    outline: none;
    box-shadow: none;
}
#ai-submit-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#ai-submit-button svg {
    fill: var(--accent-primary);
    transition: fill 0.2s;
}
#ai-submit-button:hover svg {
    fill: var(--accent-tertiary);
}
#ai-submit-button:disabled svg {
    fill: var(--border-color);
    cursor: not-allowed;
}
.chat-message pre {
    background-color: var(--bg-main);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
}
.chat-message code {
    font-family: 'Courier New', Courier, monospace;
}

/* --- FAQ Section --- */
.faq-item {
    border-bottom: 1px solid var(--border-color);
}
.faq-question {
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    position: relative;
}
.faq-question::after {
    content: '+';
    position: absolute;
    right: 1rem;
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}
.faq-answer p {
    padding: 0 1rem 1rem 1rem;
    margin: 0;
    color: var(--text-secondary);
}
.faq-item.active .faq-question::after {
    transform: rotate(45deg);
}
.faq-item.active .faq-answer {
    max-height: 300px; /* Adjust as needed */
    padding: 0;
}

/* --- Responsive Design --- */
@media (max-width: 920px) { #scientific-panel .buttons { grid-template-columns: repeat(6, 1fr); } .site-header { flex-direction: column; gap: 1rem; } }
@media (max-width: 768px) {
    #scientific-panel .buttons { grid-template-columns: repeat(5, 1fr); }
    .tool-grid { grid-template-columns: 1fr; }
    .site-header .main-site-nav ul { gap: 1rem; }
}
@media (max-width: 600px) {
    #scientific-panel .buttons { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    #scientific-panel .buttons button { font-size: 0.9rem; padding: 0.7rem; }
}
