/* style.css - Advanced Data Analysis Calculator */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: #3b82f6;
    text-decoration: none;
}

/* Main Layout */
.lg-flex {
    display: flex;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.content-area {
    flex: 1;
    min-width: 300px;
}

.sidebar {
    width: 300px;
    min-width: 250px;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Typography */
h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.subtitle {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

h2, h3, h4 {
    color: #1f2937;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-info {
    background: #8b5cf6;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #7c3aed;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Input Groups */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group input.invalid {
    border-color: #ef4444;
    background-color: #fef2f2;
}

/* Data Table */
.data-table-container {
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.data-table th {
    background: #f9fafb;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.data-table tr:hover td {
    background-color: #f9fafb;
}

.data-table input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s;
}

.data-table input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.data-table input.invalid {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.data-count {
    color: #6b7280;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.empty-row {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 3rem !important;
}

.empty-row i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Table Action Buttons */
.btn-table {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-table i {
    font-size: 0.875rem;
}

.btn-remove-row {
    padding: 0.25rem 0.5rem;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-remove-row:hover {
    background: #ef4444;
    color: white;
}

/* Loading Indicator */
.table-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    display: none;
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
    margin-top: 2rem;
    display: none;
}

.dataset-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f0f9ff;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.dataset-info span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dataset-info i {
    color: #3b82f6;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-item {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.result-label {
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-label i {
    color: #6b7280;
}

.result-value {
    font-size: 1.25rem;
    color: #111827;
    font-weight: 500;
    word-break: break-word;
}

.result-value.outliers {
    color: #dc2626;
}

/* Lists */
.result-list {
    max-height: 150px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.result-list div {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.result-list div:last-child {
    border-bottom: none;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    margin: 2rem 0;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 1rem;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Interpretation Guide */
.interpretation-guide {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f0f9ff;
    border-radius: 8px;
    border: 1px solid #dbeafe;
}

.interpretation-guide h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e40af;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.guide-item {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #dbeafe;
}

.guide-item strong {
    color: #1e40af;
    display: block;
    margin-bottom: 0.25rem;
}

/* Formula Display */
.formula-display {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.formula-display i {
    color: #3b82f6;
}

/* Error Messages */
.error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
    display: none;
}

.error-message i {
    font-size: 1.25rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Success Messages */
.success-message {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
    display: none;
}

/* Sidebar */
.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.sidebar-link i {
    color: #6b7280;
    width: 1.25rem;
}

.sidebar-tips {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-tips p {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

.sidebar-tips strong {
    color: #374151;
}

/* Footer */
footer {
    background: white;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    color: #6b7280;
}

/* Responsive Design */
@media (max-width: 768px) {
    .lg-flex {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-buttons {
        justify-content: center;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
    }
    
    .guide-grid {
        grid-template-columns: 1fr;
    }
    
    .dataset-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .table-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .table-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    .chart-container {
        height: 300px;
    }
}