@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #f8f9fa;
    --bg-header: #1e4d7b;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #ffffff;
    --title-color: #ffffff;
    --border-color: #e0e3e7;
    --shadow: rgba(0,0,0,0.1);
    --input-bg: #ffffff;
    --input-border: #ddd;
    --success-bg: #d4edda;
    --success-text: #155724;
    --success-border: #c3e6cb;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --error-border: #f5c6cb;
    --loading-bg: #d1ecf1;
    --loading-text: #0c5460;
    --loading-border: #bee5eb;
    --table-header-bg: #34495e;
    --toggle-bg: #ecf0f1;
    --toggle-border: #bdc3c7;
    --toggle-hover: #d5dbdb;
    --image-border: #ddd;
    --image-bg: #f9f9f9;
}

body.dark-mode {
    --bg-primary: #000000;
    --bg-secondary: #2d2d2d;
    --bg-header: #273941;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-light: #ffffff;
    --title-color: #ffffff;
    --border-color: #3a3a3a;
    --shadow: rgba(0,0,0,0.5);
    --input-bg: #3a3a3a;
    --input-border: #505050;
    --success-bg: #1a3a1a;
    --success-text: #90ee90;
    --success-border: #2a5a2a;
    --error-bg: #3a1a1a;
    --error-text: #ff6b6b;
    --error-border: #5a2a2a;
    --loading-bg: #1a2a3a;
    --loading-text: #64b5f6;
    --loading-border: #2a4a5a;
    --table-header-bg: #3a3a3a;
    --toggle-bg: #3a3a3a;
    --toggle-border: #505050;
    --toggle-hover: #4a4a4a;
    --image-border: #3a3a3a;
    --image-bg: #1a1a1a;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

.tab-container {
    margin-bottom: 30px;
}

.tab-nav {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    border-bottom: 2px solid var(--border-color);
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 16px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease-in-out;
    position: relative;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    background: rgba(30, 77, 123, 0.05);
    color: var(--text-primary);
}

body.dark-mode .tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--bg-header);
    color: var(--text-light);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--text-light);
}

.tab-content {
    display: none;
    padding: 0;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

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

.upload-section, .analysis-section, .overall-section {
    background: var(--bg-secondary);
    padding: 40px 30px 30px 30px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px var(--shadow);
    margin-top: -2px;
}

.upload-section h2, .analysis-section h2, .overall-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 22px;
}

.upload-controls {
    max-width: 900px;
    margin: 0 auto;
}

.upload-zone-main {
    margin-bottom: 30px;
}

.upload-area-main {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 50px 30px;
    text-align: center;
    background: var(--bg-primary);
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

.upload-area-main:hover {
    border-color: var(--bg-header);
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

.upload-area-main.dragover {
    border-color: #10b981;
    background: var(--success-bg);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 500;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.upload-btn-main {
    background: var(--bg-header);
    color: var(--text-light);
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.upload-btn-main:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.upload-btn-main.secondary {
    background: var(--text-secondary);
}

.upload-btn-main.secondary:hover {
    background: #7f8c8d;
}

.files-selected-info {
    padding: 16px;
    background: var(--success-bg);
    border: 2px solid var(--success-border);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.files-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--success-text);
    font-size: 15px;
}

.files-icon {
    font-size: 24px;
    color: #10b981;
}

.clear-selection-btn {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.clear-selection-btn:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-1px);
}

.action-section {
    text-align: center;
    margin-top: 30px;
}

.process-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 14px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-family: 'Inter', sans-serif;
}

.process-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.process-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    margin-right: 8px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    text-align: center;
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease-in-out;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.stat-number {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--bg-header);
    margin-bottom: 8px;
    font-family: 'Inter', monospace;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.class-breakdown {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    border: 1px solid var(--border-color);
}

.class-breakdown h3 {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.class-breakdown .class-table {
    margin-top: 20px;
}

header {
    background: var(--bg-header);
    color: var(--text-light);
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 26px;
    font-weight: 600;
    flex: 1;
    color: var(--title-color);
    letter-spacing: 0.5px;
}

.theme-toggle {
    background: transparent;
    border: 2px solid var(--text-light);
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}


.control-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: flex-end;
}

.control-group {
    flex: 1;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 15px;
}

.control-group input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.control-group input[type="text"]:disabled {
    background: var(--toggle-bg);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.control-group input[type="range"] {
    width: 100%;
}

.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    width: 100%;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

#status-message {
    padding: 12px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 15px;
    font-weight: 500;
}

#status-message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

#status-message.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

#status-message.loading {
    background: var(--loading-bg);
    color: var(--loading-text);
    border: 1px solid var(--loading-border);
}

.image-card {
    background: var(--bg-secondary);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
}

.card-top {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 15px;
    margin-bottom: 10px;
}

.dropdown-toggle {
    width: 100%;
    padding: 10px;
    background: var(--toggle-bg);
    border: 1px solid var(--toggle-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 10px;
    transition: background 0.2s;
}

.dropdown-toggle:hover {
    background: var(--toggle-hover);
}

.dropdown-toggle .arrow {
    display: inline-block;
    transition: transform 0.2s;
}

.dropdown-toggle.expanded .arrow {
    transform: rotate(180deg);
}

.card-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 1;
}

.card-bottom.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.image-column {
    display: flex;
    flex-direction: column;
}

.image-column h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
}

.image-wrapper {
    position: relative;
    width: 100%;
    border: 2px solid var(--image-border);
    border-radius: 4px;
    overflow: hidden;
    background: var(--image-bg);
}

.image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.image-wrapper.clickable {
    cursor: pointer;
}

.image-wrapper.clickable:hover {
    border-color: #3498db;
}

.controls-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.threshold-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.threshold-group label {
    font-size: 14px;
    font-weight: 500;
}

.threshold-group input[type="range"] {
    width: 100%;
}

.threshold-value {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.class-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.class-table thead {
    background: var(--table-header-bg);
}

.class-table th {
    color: var(--text-light);
    padding: 10px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.class-table th:first-child {
    border-radius: 6px 0 0 0;
}

.class-table th:last-child {
    border-radius: 0 6px 0 0;
}

.class-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.class-name {
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.class-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.toggle-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    min-width: 50px;
}

.toggle-btn.on {
    background: #27ae60;
    color: white;
}

.toggle-btn.off {
    background: #e74c3c;
    color: white;
}

.toggle-btn:hover {
    opacity: 0.8;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
}

body.dark-mode .modal {
    background-color: rgba(0,0,0,0.95);
}

.modal-content {
    position: relative;
    margin: 5% auto;
    padding: 20px;
    width: fit-content;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 90vh;
    display: block;
    transform: scale(0.75);
    transform-origin: center;
}

.close {
    position: absolute;
    top: 10px;
    right: 25px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #ccc;
}

.loading {
    text-align: center;
    padding: 20px;
    font-size: 16px;
    color: #666;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.info-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.info-modal.show {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.modal-overlay-info {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content-info {
    position: relative;
    background: var(--bg-secondary);
    max-width: 600px;
    margin: 100px auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 2001;
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-header);
    border-radius: 12px 12px 0 0;
}

.info-icon {
    font-size: 28px;
}

.modal-header-info h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-light);
}

.modal-body-info {
    padding: 24px;
}

.validation-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.summary-icon {
    font-size: 20px;
}

.summary-item.valid .summary-icon {
    color: #10b981;
}

.summary-item.invalid .summary-icon {
    color: #f59e0b;
}

#invalid-files-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.invalid-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 3px solid #f59e0b;
    font-size: 14px;
}

.file-icon {
    font-size: 18px;
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
}

.file-reason {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.validation-note {
    padding: 12px;
    background: var(--loading-bg);
    border-radius: 6px;
    border: 1px solid var(--loading-border);
}

.validation-note p {
    margin: 0;
    font-size: 14px;
    color: var(--loading-text);
}

.modal-actions-info {
    padding: 20px 24px;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-proceed {
    background: #10b981;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.btn-proceed:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-cancel-info {
    background: var(--text-secondary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.btn-cancel-info:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

body.dark-mode .analysis-section,
body.dark-mode .overall-section,
body.dark-mode .upload-section {
    background: #212121;
}

body.dark-mode .image-card {
    background: #303030;
}

body.dark-mode .stat-item {
    background: #303030;
}

body.dark-mode .class-breakdown {
    background: #303030;
}

.impact-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.impact-column h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.severity-indicator {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.severity-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

.severity-bar-container {
    position: relative;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.severity-bar-fill {
    height: 100%;
    transition: width 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.severity-bar-fill.low {
    background: linear-gradient(90deg, #10b981, #059669);
}

.severity-bar-fill.medium {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.severity-bar-fill.high {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.severity-value {
    font-size: 13px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.impact-metrics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.impact-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 12px;
}

.impact-metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.impact-metric-name {
    font-weight: 600;
    color: var(--text-primary);
}

.impact-metric-value {
    font-weight: 700;
    color: var(--text-primary);
}

.impact-progress-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.impact-progress-fill {
    height: 100%;
    background: var(--bg-header);
    transition: width 0.3s ease-in-out;
}

body.dark-mode .impact-progress-fill {
    background: #3b82f6;
}

body.dark-mode .impact-progress-bar {
    background: #1a1a1a;
}

body.dark-mode .severity-bar-container {
    background: #1a1a1a;
}

.hazard-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.hazard-badge.none {
    background: #d4edda;
    color: #155724;
}

.hazard-badge.possible {
    background: #fff3cd;
    color: #856404;
}

.hazard-badge.likely {
    background: #f8d7da;
    color: #721c24;
}

body.dark-mode .hazard-badge.none {
    background: #1a3a1a;
    color: #90ee90;
}

body.dark-mode .hazard-badge.possible {
    background: #3a3a1a;
    color: #ffc107;
}

body.dark-mode .hazard-badge.likely {
    background: #3a1a1a;
    color: #ff6b6b;
}
