/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 8px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 3px;
    font-size: 1.5rem;
    font-weight: 300;
}

header p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

/* Main Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .data-input {
        max-width: 100%;
    }
}

/* Section Styles */
section {
    background: white;
    padding: 8px;
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

section h2 {
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 1px solid #3498db;
    padding-bottom: 2px;
}

/* Simple Spreadsheet-like Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 5px;
    font-family: Arial, sans-serif;
    font-size: 12px;
}

th {
    background: #f0f0f0;
    color: #333;
    font-weight: normal;
    padding: 3px 2px;
    text-align: center;
    border: 1px solid #ccc;
    width: 50%;
}

td {
    padding: 1px;
    border: 1px solid #ccc;
    background: white;
    width: 50%;
}

td input {
    width: 100%;
    padding: 1px 2px;
    border: none;
    background: transparent;
    font-size: 12px;
    text-align: center;
    outline: none;
}

td input:focus {
    background: #e3f2fd;
    border: 1px solid #2196f3;
}

tr:nth-child(even) td {
    background: #f9f9f9;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Compact Controls */
.analysis-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.analysis-controls .btn {
    padding: 4px 8px;
    font-size: 11px;
    margin: 0;
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.analysis-controls {
    text-align: center;
    margin-top: 20px;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Tangent Controls */
.tangent-controls {
    display: none;
}

.tangent-controls.visible {
    display: block;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 768px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
}

/* Slider Styles */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-container label {
    font-weight: 500;
    color: #2c3e50;
}

#xSlider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#xSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}

#xSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}

#xValue {
    font-size: 1.2rem;
    font-weight: bold;
    color: #3498db;
    text-align: center;
    padding: 5px;
    background: #ecf0f1;
    border-radius: 5px;
}

/* Results Display */
.results {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.result-item label {
    font-weight: 500;
    color: #2c3e50;
}

.result-item span {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #27ae60;
}

/* Equation Display */
.equation-display {
    display: none;
}

.equation-display.visible {
    display: block;
}

.equation {
    text-align: center;
    margin-bottom: 20px;
}

.equation span {
    font-size: 1.5rem;
    font-family: 'Courier New', monospace;
    color: #2c3e50;
    background: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    display: inline-block;
}

.coefficients {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.coefficients div {
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.r-squared {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
    background: #d5f4e6;
    padding: 10px;
    border-radius: 8px;
}

/* Status Messages */
.status {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.status.error {
    background: #fdf2f2;
    color: #e53e3e;
    border: 1px solid #fed7d7;
    display: block;
}

.status.success {
    background: #f0fff4;
    color: #38a169;
    border: 1px solid #c6f6d5;
    display: block;
}

.status.info {
    background: #ebf8ff;
    color: #3182ce;
    border: 1px solid #bee3f8;
    display: block;
}

/* Analysis Results Section */
.analysis-results {
    display: none;
    padding: 10px;
}

.analysis-results.show {
    display: block;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.equation-section h3,
.point-info h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1rem;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 3px;
}

.point-info {
    display: none;
}

.point-info.show {
    display: block;
}

.point-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.point-details div {
    padding: 5px;
    background: #f8f9fa;
    border-radius: 3px;
    border-left: 2px solid #3498db;
    font-size: 14px;
}

#fitBtn {
    display: none;
}

#fitBtn.show {
    display: inline-block;
}

/* Graph Info Box */
.graph-info-box {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 8px;
    font-size: 12px;
    min-width: 150px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
}

.graph-info-box.show {
    display: block;
}

.graph-info-box .info-item {
    margin-bottom: 3px;
}

.graph-info-box .info-label {
    font-weight: bold;
    color: #2c3e50;
}

.graph-info-box .info-value {
    color: #e74c3c;
}

/* Data Input Section Specific Styling */
.data-input {
    max-width: 280px;
}

.data-input table {
    font-size: 11px;
}

.data-input th {
    padding: 2px 1px;
    font-size: 11px;
}

.data-input td {
    padding: 0;
}

.data-input td input {
    padding: 1px;
    font-size: 11px;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .coefficients {
        grid-template-columns: 1fr;
    }
    
    th, td {
        padding: 8px;
        font-size: 14px;
    }
    
    .result-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
}
