/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

header nav {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

header nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

header nav a.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
}

/* Section headers */
.section-header {
    margin: 30px 0 20px 0;
    text-align: center;
}

.section-header h2 {
    color: white;
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin: 0;
}

/* Filters section */
.filters, .filters-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    justify-content: flex-start;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.filter-group:first-child {
    flex: 2;
    min-width: 250px;
}


.filter-group label {
    font-weight: 600;
    margin-bottom: 6px;
    color: #4a5568;
    font-size: 0.85rem;
}

/* Multi-select dropdown */
.multi-select-container {
    position: relative;
}

.multi-select-header {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 300px;
    transition: all 0.3s ease;
}

.multi-select-header:hover {
    border-color: #667eea;
}

.multi-select-header.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.multi-select-header .placeholder {
    color: #718096;
}

.multi-select-header .arrow {
    transition: transform 0.3s ease;
}

.multi-select-header.active .arrow {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.multi-select-dropdown.show {
    display: block;
}

.multi-select-option {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    transition: background-color 0.2s ease;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
}

.multi-select-option:hover {
    background-color: #f7fafc;
}

.multi-select-option input[type="checkbox"] {
    margin-right: 8px;
}

.multi-select-option.selected {
    background-color: #ebf8ff;
    color: #3182ce;
}

/* Standard form elements */
select, input[type="date"] {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: #f7fafc;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    height: 40px;
}

/* Compact interval and date inputs */
#interval-select {
    padding: 8px 8px;
    font-size: 0.85rem;
    width: 100%;
    max-width: 120px;
}

#date-from, #date-to, .date-input {
    padding: 8px 8px;
    font-size: 0.85rem;
    width: 100%;
    max-width: 130px;
}

select:focus, input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Upload button */
.upload-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(72, 187, 120, 0.3);
}

.file-upload-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.uploaded-files {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 120px;
    overflow-y: auto;
}

.uploaded-file {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    color: #2f855a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.uploaded-file .remove-file {
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

.uploaded-file .remove-file:hover {
    background: #c53030;
}

/* Analyze button */
.analyze-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    height: 40px;
    white-space: nowrap;
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.analyze-btn:active {
    transform: translateY(0);
}

.analyze-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Apply filters button */
.apply-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.3);
}

/* Export button */
.export-btn {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 200px;
}

.export-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(56, 161, 105, 0.3);
}



/* Results section */
.results-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.chart-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    height: 650px;
    position: relative;
    overflow: hidden;
}

.statistics-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    height: fit-content;
}

.statistics-container h3 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

/* Statistics comparison table */
.stats-table-container {
    overflow-x: auto;
    margin-top: 10px;
}

.stats-comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
}

.stats-comparison-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stats-comparison-table th,
.stats-comparison-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.metric-header {
    font-weight: 600;
    min-width: 160px;
    position: sticky;
    left: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 2;
}

.stock-header {
    font-weight: 600;
    min-width: 120px;
    text-align: center;
    white-space: nowrap;
}

.metric-label {
    font-weight: 600;
    color: #4a5568;
    background: #f8fafc;
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 2px solid #e2e8f0;
}

.metric-value {
    text-align: center;
    font-weight: 500;
    color: #2d3748;
}

.metric-value.positive {
    color: #48bb78;
    font-weight: 600;
}

.metric-value.negative {
    color: #f56565;
    font-weight: 600;
}

.metric-value.highlight {
    color: #805ad5;
    font-weight: 600;
    background: #faf5ff;
}

.stats-comparison-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.stats-comparison-table tbody tr:hover {
    background: #edf2f7;
}

.no-data {
    text-align: center;
    color: #718096;
    padding: 20px;
    font-style: italic;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    display: none;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 1.2rem;
    color: #4a5568;
    font-weight: 600;
}

/* Selected stocks display */
.selected-stocks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.selected-stock {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.selected-stock .remove {
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.selected-stock .remove:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive design */
@media (max-width: 1024px) {
    /* Results section already uses single column layout */
    
    .filters-section {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .analyze-btn {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .filters-section {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 20px;
    }
    
    .analyze-btn {
        width: 100%;
    }
    
    .chart-container,
    .statistics-container {
        padding: 20px;
    }
}

/* Chart.js custom styles */
.chart-wrapper {
    position: relative;
    height: 590px;
    width: 100%;
    overflow: hidden;
}

.chart-container canvas {
    max-width: 100% !important;
    max-height: 590px !important;
    height: 590px !important;
    width: 100% !important;
    display: block;
}

/* Error message */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #f56565;
}

.success-message {
    background: #c6f6d5;
    color: #2f855a;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #48bb78;
}

/* Restored notification */
.restored-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
    z-index: 10001;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Filter Info Lines */
.filter-info {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    border-radius: 4px;
    font-style: italic;
}

@media (max-width: 768px) {
    .filter-info {
        font-size: 0.85rem;
        padding: 6px 10px;
        margin-bottom: 12px;
    }
}

/* Price Chart Container */
.price-chart-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-top: 20px;
    height: 550px;
    position: relative;
    overflow: hidden;
}

.price-chart-container .chart-wrapper {
    position: relative;
    height: 490px;
    width: 100%;
    overflow: hidden;
}

.price-chart-container canvas {
    max-width: 100% !important;
    max-height: 490px !important;
    height: 490px !important;
    width: 100% !important;
    display: block;
}



/* Details Container */
.details-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-top: 20px;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.details-header h3 {
    color: #4a5568;
    margin: 0;
    font-size: 1.3rem;
}

.details-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.details-filter label {
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.details-filter select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    min-width: 200px;
}

.details-filter select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Details Table */
.details-table {
    overflow-x: auto;
    margin-top: 15px;
}

.details-data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
}

.details-data-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.details-data-table th,
.details-data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.details-data-table th {
    font-weight: 600;
    white-space: nowrap;
}

.details-data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.details-data-table tbody tr:hover {
    background: #edf2f7;
}

.details-data-table .date-col {
    min-width: 100px;
}

.details-data-table .price-col {
    text-align: right;
    min-width: 80px;
}

.details-data-table .return-col {
    text-align: right;
    font-weight: 600;
    min-width: 80px;
}

.details-data-table .return-positive {
    color: #48bb78;
}

.details-data-table .return-negative {
    color: #f56565;
}

.details-data-table .return-zero {
    color: #718096;
}

.details-data-table .indicator-col {
    text-align: center;
    min-width: 60px;
    font-weight: 600;
    font-size: 1.1rem;
}

.details-data-table .indicator-positive {
    color: #48bb78;
}

.details-data-table .indicator-negative {
    color: #f56565;
}

/* Table Controls */
.table-controls {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.table-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

.table-controls-row:last-child {
    margin-bottom: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
    font-size: 0.9rem;
}

.control-group input,
.control-group select {
    padding: 6px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 120px;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.table-info {
    color: #718096;
    font-size: 0.9rem;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid #cbd5e0;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #edf2f7;
    border-color: #a0aec0;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f7fafc;
}

#page-info {
    font-size: 0.9rem;
    color: #4a5568;
    font-weight: 500;
    white-space: nowrap;
}

/* Sortable table headers */
.details-data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
}

.details-data-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
}

.details-data-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 0.8rem;
}

.details-data-table th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.details-data-table th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
}

@media (max-width: 768px) {
    .table-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .control-group {
        justify-content: space-between;
    }
    
    .control-group input,
    .control-group select {
        min-width: auto;
        flex: 1;
    }
    
    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .pagination-btn {
        padding: 8px 12px;
    }
}

@media (max-width: 768px) {
    .details-container {
        padding: 20px;
    }
    
    .details-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .details-filter {
        width: 100%;
    }
    
    .details-filter select {
        flex: 1;
        min-width: auto;
    }
    
    .details-data-table {
        font-size: 0.8rem;
    }
    
    .details-data-table th,
    .details-data-table td {
        font-size: 0.8rem;
        padding: 6px;
    }
}

/* Download Data Page Specific Styles */
.download-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    margin-top: 20px;
}

.download-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.download-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    min-height: 20px;
}

.download-status.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.download-status.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

.scheme-search {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 1rem;
    color: #2d3748;
    padding: 0;
}

.scheme-search::placeholder {
    color: #a0aec0;
}

.scheme-name {
    font-weight: 500;
    color: #2d3748;
}

.scheme-code {
    font-size: 0.85rem;
    color: #718096;
    margin-left: 8px;
}

.dropdown-arrow {
    color: #718096;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.multi-select-header.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Enhanced loading overlay for download */
.loading-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.loading-overlay p {
    color: #4a5568;
    font-weight: 500;
    margin-top: 15px;
}

/* Responsive design for download page */
@media (max-width: 768px) {
    .download-btn {
        width: 100%;
        padding: 15px 24px;
        font-size: 1.1rem;
    }
    
    .scheme-search {
        font-size: 1.1rem;
    }
    
    .multi-select-option {
        padding: 12px 15px;
    }
} 

/* Validation error messages */
.validation-error {
    color: #e74c3c;
    background-color: #fdf2f2;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 0.85rem;
    display: none;
}

.validation-error:not(:empty) {
    display: block;
} 