:root {
    --primary-color: #4a90d9;
    --secondary-color: #50c878;
    --accent-color: #ff6b6b;
    --warning-color: #ffa502;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #6c757d;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.tab-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Canvas Containers */
.canvas-container,
.proof-canvas-container,
.practice-canvas-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

canvas {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: crosshair;
    display: block;
    max-width: 100%;
    width: min(100%, 800px);
    height: auto;
    aspect-ratio: 16 / 10;
}

#triangleCanvas {
    cursor: grab;
}

#triangleCanvas:active {
    cursor: grabbing;
}

/* Info Panel */
.info-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.formula-display {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.formula-display h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.formula-main {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 10px;
}

.formula {
    font-family: 'Times New Roman', serif;
    font-style: italic;
}

.formula-current {
    font-size: 1.2rem;
    color: var(--secondary-color);
    font-family: 'Times New Roman', serif;
    min-height: 30px;
}

.measurements {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.measurement-group h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.measurement-item {
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.measurement-item .label {
    font-weight: 500;
    color: var(--text-color);
}

.measurement-item .value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.triangle-type {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.verification {
    margin-top: 20px;
}

.verification h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

#verificationSteps {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

/* Proof Section */
.proof-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.proof-steps {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.proof-steps h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.step-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
}

.step-btn {
    padding: 10px 20px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.step-btn:hover {
    background: #357abd;
    transform: translateY(-2px);
}

.step-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

#stepIndicator {
    font-weight: bold;
    color: var(--text-color);
}

.step-explanation {
    margin-bottom: 20px;
}

.step-explanation h4 {
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

#stepContent {
    line-height: 1.8;
}

.proof-formula {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    font-family: 'Times New Roman', serif;
    font-size: 1.3rem;
    text-align: center;
    border-left: 4px solid var(--primary-color);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Examples Section */
.examples-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.examples-container h3 {
    color: var(--primary-color);
    margin-bottom: 25px;
    text-align: center;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.example-card {
    background: var(--bg-color);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
}

.example-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.example-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.example-card p {
    color: #6c757d;
    margin-bottom: 15px;
}

.load-example {
    padding: 10px 20px;
    border: none;
    background: var(--secondary-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-example:hover {
    background: #45b369;
    transform: scale(1.05);
}

.example-detail {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 100px;
    border-left: 4px solid var(--secondary-color);
}

/* Practice Section */
.practice-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.practice-container h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
}

.practice-modes {
    margin-bottom: 20px;
}

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.mode-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 20px;
    background: var(--bg-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mode-selector label:hover {
    background: var(--primary-color);
    color: white;
}

.mode-selector input[type="radio"] {
    cursor: pointer;
}

.practice-problem {
    margin-top: 20px;
}

.problem-description {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.problem-input {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group label {
    font-weight: 500;
    min-width: 50px;
}

.input-group input {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-group input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
}

.practice-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.practice-btn {
    padding: 12px 24px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.practice-btn:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.practice-btn.secondary {
    background: var(--warning-color);
}

.practice-btn.secondary:hover {
    background: #e69500;
}

.practice-result {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    min-height: 80px;
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.practice-result.correct {
    background: #d4edda;
    border: 2px solid var(--secondary-color);
    color: #155724;
}

.practice-result.incorrect {
    background: #f8d7da;
    border: 2px solid var(--accent-color);
    color: #721c24;
}

.practice-history {
    margin-top: 30px;
}

.practice-history h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

#historyList {
    display: grid;
    gap: 10px;
}

.history-item {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item.correct {
    border-left: 4px solid var(--secondary-color);
}

.history-item.incorrect {
    border-left: 4px solid var(--accent-color);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .proof-container {
        grid-template-columns: 1fr;
    }

    .measurements {
        grid-template-columns: 1fr;
    }

    .example-grid {
        grid-template-columns: 1fr;
    }

    .practice-controls {
        flex-direction: column;
    }

    .practice-btn {
        width: 100%;
    }

    .mode-selector {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 2s infinite;
}
