/* ========== Newton Fractal Visualization Styles ========== */

/* ========== CSS Variables ========== */
:root {
    --newton-primary-color: #6c5ce7;
    --newton-secondary-color: #2d3436;
    --newton-accent-color: #e17055;
    --newton-bg-color: #f5f6fa;
    --newton-card-bg: #ffffff;
    --newton-text-color: #2d3436;
    --newton-border-color: #dfe6e9;
    --newton-success-color: #00b894;
}

/* ========== Global Reset ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========== Container ========== */
.newton-fractal-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--newton-bg-color);
    color: var(--newton-text-color);
    line-height: 1.6;
}

/* ========== Header ========== */
.newton-fractal-container header {
    text-align: center;
    margin-bottom: 30px;
}

.newton-fractal-container h1 {
    font-size: 2.5rem;
    color: var(--newton-secondary-color);
    margin-bottom: 10px;
}

.newton-fractal-container .subtitle {
    font-size: 1.2rem;
    color: #636e72;
}

/* ========== Main Layout ========== */
.newton-fractal-container .main-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .newton-fractal-container .main-layout {
        grid-template-columns: 1fr;
    }
}

/* ========== Canvas Section ========== */
.newton-fractal-container .canvas-section {
    background: var(--newton-card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.newton-fractal-container .canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.newton-fractal-container #newtonCanvas {
    width: 100%;
    max-width: 900px;
    border: 2px solid var(--newton-border-color);
    border-radius: 8px;
    background: #000;
    cursor: crosshair;
}

.newton-fractal-container .canvas-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.newton-fractal-container .coord-info {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    pointer-events: none;
}

/* ========== Render Controls ========== */
.newton-fractal-container .render-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.newton-fractal-container .control-row {
    display: flex;
    flex-direction: column;
}

.newton-fractal-container .control-row label {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--newton-secondary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.newton-fractal-container .control-row input[type="range"] {
    width: 100%;
    cursor: pointer;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.newton-fractal-container .control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--newton-primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

.newton-fractal-container .control-row input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--newton-accent-color);
}

.newton-fractal-container .control-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--newton-primary-color);
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.newton-fractal-container .control-row input[type="range"]::-moz-range-thumb:hover {
    background: var(--newton-accent-color);
}

.newton-fractal-container .control-row select {
    padding: 8px 12px;
    border: 1px solid var(--newton-border-color);
    border-radius: 4px;
    background: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.newton-fractal-container .control-row select:hover {
    border-color: var(--newton-primary-color);
}

.newton-fractal-container .control-row select:focus {
    outline: none;
    border-color: var(--newton-primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* ========== Button Group ========== */
.newton-fractal-container .button-group {
    display: flex;
    gap: 10px;
    grid-column: 1 / -1;
    margin-top: 10px;
}

.newton-fractal-container .btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.newton-fractal-container .btn-primary {
    background: var(--newton-primary-color);
    color: #fff;
}

.newton-fractal-container .btn-primary:hover {
    background: #5b4cdb;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.newton-fractal-container .btn-secondary {
    background: var(--newton-accent-color);
    color: #fff;
}

.newton-fractal-container .btn-secondary:hover {
    background: #d35400;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.newton-fractal-container .btn.active {
    background: var(--newton-success-color);
}

.newton-fractal-container .btn:active {
    transform: translateY(0);
}

/* ========== Side Panel ========== */
.newton-fractal-container .side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.newton-fractal-container .panel-section {
    background: var(--newton-card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.newton-fractal-container .panel-section h3 {
    color: var(--newton-secondary-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
}

.newton-fractal-container .panel-description {
    font-size: 0.9rem;
    color: #636e72;
    margin-bottom: 15px;
}

/* ========== Formula Display ========== */
.newton-fractal-container .formula-display {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.5rem;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
    color: var(--newton-secondary-color);
}

.newton-fractal-container .formula-f,
.newton-fractal-container .formula-fp {
    color: var(--newton-primary-color);
    font-weight: bold;
}

.newton-fractal-container .formula-detail {
    font-family: 'Courier New', monospace;
    text-align: center;
    font-size: 1rem;
    color: var(--newton-secondary-color);
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    line-height: 1.8;
}

/* ========== Roots List ========== */
.newton-fractal-container .roots-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.newton-fractal-container .root-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.newton-fractal-container .root-item:hover {
    background: #e9ecef;
    border-color: var(--newton-primary-color);
}

.newton-fractal-container .root-item.highlighted {
    background: rgba(108, 92, 231, 0.1);
    border-color: var(--newton-primary-color);
}

.newton-fractal-container .root-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.newton-fractal-container .root-info {
    display: flex;
    flex-direction: column;
}

.newton-fractal-container .root-number {
    font-weight: 600;
    color: var(--newton-secondary-color);
    font-size: 0.9rem;
}

.newton-fractal-container .root-value {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #636e72;
}

/* ========== Legend ========== */
.newton-fractal-container .legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.newton-fractal-container .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.85rem;
}

.newton-fractal-container .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.newton-fractal-container .legend-note {
    font-size: 0.8rem;
    color: #636e72;
    font-style: italic;
}

/* ========== View Info ========== */
.newton-fractal-container .view-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.newton-fractal-container .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.newton-fractal-container .info-row:last-child {
    border-bottom: none;
}

.newton-fractal-container .info-row span:first-child {
    font-weight: 600;
    color: var(--newton-secondary-color);
}

.newton-fractal-container .info-value {
    font-family: 'Courier New', monospace;
    color: var(--newton-primary-color);
    font-weight: bold;
}

/* ========== Educational Content ========== */
.newton-fractal-container .educational-content {
    display: grid;
    gap: 20px;
}

.newton-fractal-container .edu-section {
    background: var(--newton-card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.newton-fractal-container .edu-section h3 {
    color: var(--newton-secondary-color);
    margin-bottom: 15px;
    font-size: 1.4rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.newton-fractal-container .edu-section p {
    margin-bottom: 12px;
    color: var(--newton-text-color);
    line-height: 1.8;
}

.newton-fractal-container .edu-section ul {
    margin-left: 25px;
    margin-top: 10px;
}

.newton-fractal-container .edu-section li {
    margin-bottom: 10px;
    line-height: 1.8;
}

.newton-fractal-container .edu-section strong {
    color: var(--newton-secondary-color);
}

.newton-fractal-container .formula-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
}

.newton-fractal-container .formula-box .formula {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.3rem;
    color: var(--newton-primary-color);
    padding: 10px 0;
    text-align: center;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .newton-fractal-container h1 {
        font-size: 2rem;
    }

    .newton-fractal-container .subtitle {
        font-size: 1rem;
    }

    .newton-fractal-container .render-controls {
        grid-template-columns: 1fr;
    }

    .newton-fractal-container .button-group {
        flex-direction: column;
    }

    .newton-fractal-container #newtonCanvas {
        max-width: 100%;
    }

    .newton-fractal-container .canvas-overlay {
        top: 5px;
        right: 5px;
    }

    .newton-fractal-container .coord-info {
        font-size: 0.75rem;
        padding: 5px 8px;
    }
}

/* ========== Accessibility ========== */
.newton-fractal-container .btn:focus,
.newton-fractal-container .root-item:focus,
.newton-fractal-container input:focus,
.newton-fractal-container select:focus {
    outline: 2px solid var(--newton-primary-color);
    outline-offset: 2px;
}

/* ========== Print Styles ========== */
@media print {
    .newton-fractal-container .render-controls,
    .newton-fractal-container .side-panel,
    .newton-fractal-container .button-group {
        display: none;
    }

    .newton-fractal-container .main-layout {
        grid-template-columns: 1fr;
    }
}
