/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --radius: 8px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    padding: 1.5rem;
    gap: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.panel h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

select, input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select:disabled {
    background-color: var(--bg-color);
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* Parameters List */
.parameters-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
}

.parameter-item {
    display: flex;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-color);
}

.parameter-item:last-child {
    border-bottom: none;
}

.parameter-item input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.parameter-item label {
    font-size: 0.85rem;
    cursor: pointer;
    flex: 1;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.radio-label:has(input:checked) {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.radio-label input {
    display: none;
}

/* Chart Area */
.chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    min-height: 450px;
    position: relative;
}

.chart-wrapper {
    position: relative;
    height: 420px;
    width: 100%;
}

#mainChart {
    max-width: 100%;
    max-height: 420px;
}

/* Multi-select file */
#fileSelect {
    width: 100%;
    min-height: 160px;
    padding: 0.5rem;
}

#fileSelect option {
    padding: 0.4rem 0.6rem;
    margin: 2px 0;
    border-radius: 4px;
}

#fileSelect option:checked {
    background: var(--primary-color) linear-gradient(0deg, var(--primary-color) 0%, var(--primary-color) 100%);
    color: white;
}

.file-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
    text-align: center;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Data Table */
.data-table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.data-table-container h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.table-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#dataTable th, #dataTable td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#dataTable th {
    background-color: var(--bg-color);
    font-weight: 600;
    position: sticky;
    top: 0;
}

#dataTable tr:hover {
    background-color: var(--bg-color);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
}

.pagination button {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
}

.pagination button:hover {
    background-color: var(--bg-color);
}

.pagination button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Footer */
.footer {
    background: var(--card-bg);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
    color: white;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 400px;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .radio-group {
        flex-wrap: wrap;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
}

/* PWA Install Button */
.install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    z-index: 1000;
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
}

.install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.install-button:active {
    transform: translateY(0);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(37, 99, 235, 0.6);
    }
}

/* PWA Standalone Mode Adjustments */
@media (display-mode: standalone) {
    .install-button {
        display: none;
    }
    
    .header {
        padding-top: env(safe-area-inset-top, 1.5rem);
    }
}

/* Mobile optimizations for PWA */
@media (max-width: 768px) {
    .install-button {
        bottom: 80px;
        right: 15px;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

