/**
 * Podlevskikh.com - Global Styles
 * Dark theme, PDF button, share buttons, utilities
 */

/* ============= DARK THEME VARIABLES ============= */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --primary-dark: #0f2744;
    --accent: #c9a227;
    --accent-light: #e6c84a;
    --text: #2d3748;
    --text-light: #718096;
    --bg: #fafafa;
    --bg-alt: #f0f4f8;
    --white: #ffffff;
    --shadow: 0 4px 20px rgba(26, 54, 93, 0.08);
    --shadow-hover: 0 8px 30px rgba(26, 54, 93, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
    --success: #48bb78;
    --error: #f56565;
    --warning: #ed8936;
}

[data-theme="dark"] {
    --primary: #4299e1;
    --primary-light: #63b3ed;
    --primary-dark: #90cdf4;
    --accent: #f6e05e;
    --accent-light: #faf089;
    --text: #e2e8f0;
    --text-light: #a0aec0;
    --bg: #1a202c;
    --bg-alt: #2d3748;
    --white: #2d3748;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
    --success: #68d391;
    --error: #fc8181;
    --warning: #f6ad55;
}

/* ============= THEME TOGGLE BUTTON ============= */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--bg-alt);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    margin-left: 16px;
}

.theme-toggle:hover {
    border-color: var(--primary);
    background: var(--bg-alt);
}

.theme-toggle svg {
    transition: var(--transition);
    color: var(--text);
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* ============= PDF & ACTIONS BUTTONS ============= */
.pdf-download-section {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.pdf-btn, .btn-copy-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    font-family: inherit;
}

.pdf-btn {
    background: var(--error);
    color: white;
}

.pdf-btn:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

.pdf-btn svg {
    width: 18px;
    height: 18px;
}

.btn-copy-all {
    background: var(--bg-alt);
    color: var(--text);
    border-color: var(--bg-alt);
}

.btn-copy-all:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============= COPY LATEX BUTTON STATES ============= */
.copy-latex {
    position: relative;
    overflow: hidden;
}

.copy-latex.copied {
    background: var(--success) !important;
    color: white !important;
}

/* ============= SHARE BUTTONS ============= */
.share-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--bg-alt);
}

.share-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.share-btn:hover {
    transform: translateY(-2px);
}

.share-tg {
    background: #0088cc;
    color: white;
}

.share-tg:hover {
    background: #0077b5;
}

.share-vk {
    background: #4a76a8;
    color: white;
}

.share-vk:hover {
    background: #3d6691;
}

.share-wa {
    background: #25d366;
    color: white;
}

.share-wa:hover {
    background: #1da851;
}

.share-copy {
    background: var(--bg-alt);
    color: var(--text);
}

.share-copy:hover {
    background: var(--primary);
    color: white;
}

/* ============= DARK THEME SPECIFIC FIXES ============= */
[data-theme="dark"] .nav {
    background: rgba(26, 32, 44, 0.95);
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-alt) 100%);
}

[data-theme="dark"] .formula-main {
    background: var(--bg-alt);
}

[data-theme="dark"] .calc-card,
[data-theme="dark"] .info-card,
[data-theme="dark"] .problem-card,
[data-theme="dark"] .question-card,
[data-theme="dark"] .results-card,
[data-theme="dark"] .toc,
[data-theme="dark"] .faq-item {
    background: var(--white);
}

[data-theme="dark"] .result-box {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

[data-theme="dark"] body {
    color: var(--text);
    background: var(--bg);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: var(--primary-dark);
}

[data-theme="dark"] a {
    color: var(--primary);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg);
    border-color: var(--bg-alt);
    color: var(--text);
}

[data-theme="dark"] .option:hover {
    background: var(--bg);
}

[data-theme="dark"] .solution-content {
    background: var(--bg);
}

[data-theme="dark"] .solution-step {
    background: var(--white);
}

/* ============= PRINT STYLES ============= */
@media print {
    .nav,
    .footer,
    .theme-toggle,
    .pdf-btn,
    .btn-copy-all,
    .share-buttons,
    .cta,
    .solution-toggle,
    .calc-btn,
    .nav-buttons,
    .related-links {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .hero {
        background: white !important;
        padding-top: 20px !important;
    }

    .formula-card,
    .problem-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    .solution {
        max-height: none !important;
    }

    a {
        color: black !important;
        text-decoration: underline;
    }
}

/* ============= DIAGRAM STYLES (for Problems) ============= */
.problem-diagram {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-alt);
    border-radius: var(--radius);
}

.problem-diagram svg {
    max-width: 100%;
    height: auto;
}

[data-theme="dark"] .problem-diagram svg text {
    fill: var(--text);
}

[data-theme="dark"] .problem-diagram svg .axis-line {
    stroke: var(--text-light);
}

/* ============= PROGRESS INDICATOR (for Tests) ============= */
.saved-progress-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.saved-progress-indicator svg {
    width: 16px;
    height: 16px;
}

/* ============= QUESTION TYPES (for enhanced tests) ============= */
/* Question type badge */
.q-type {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-alt);
    color: var(--text-light);
    font-weight: 500;
    margin-left: 8px;
}

/* Numeric input */
.numeric-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.num-answer {
    max-width: 200px;
    padding: 14px 18px;
    border: 2px solid var(--bg-alt);
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: inherit;
    text-align: center;
    background: var(--white);
    color: var(--text);
}

.num-answer:focus {
    outline: none;
    border-color: var(--primary);
}

.input-hint {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Matching question with select */
.matching-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}

.matching-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 8px;
}

.matching-left {
    flex: 1;
    font-weight: 500;
}

.matching-select {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--bg-alt);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
}

.matching-select:focus {
    outline: none;
    border-color: var(--primary);
}

@media (max-width: 600px) {
    .matching-row {
        flex-direction: column;
        align-items: stretch;
    }

    .matching-left {
        margin-bottom: 8px;
    }
}

/* ============= THEORY SECTION (Calculator pages) ============= */
.theory-section {
    margin-top: 40px;
}

.theory-section h2 {
    font-size: 1.6rem;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg-alt);
}

.theory-section h3 {
    font-size: 1.2rem;
    margin: 24px 0 12px;
    color: var(--primary);
}

.theory-section h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.theory-section p {
    margin-bottom: 12px;
}

.theory-section ul {
    margin: 12px 0 12px 24px;
}

.theory-section li {
    margin-bottom: 6px;
}

.theory-section .formula-highlight {
    background: var(--bg-alt);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
    font-size: 1.3rem;
}

.theory-section .example {
    background: var(--bg-alt);
    padding: 20px;
    border-radius: 8px;
    margin: 24px 0;
}

.theory-section .example h4 {
    color: var(--primary-dark);
    margin-bottom: 16px;
}

[data-theme="dark"] .theory-section h3 {
    color: var(--primary-light);
}

/* ============= RESPONSIVE ADJUSTMENTS ============= */
@media (max-width: 768px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
        margin-left: 8px;
    }

    .pdf-download-section {
        flex-direction: column;
    }

    .share-buttons {
        flex-wrap: wrap;
    }
}
