/* Domostav Estimate Processor - Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Confidence colors */
    --conf-high: #c6efce;
    --conf-medium: #ffeb9c;
    --conf-low: #ffcc99;
    --conf-manual: #ffc7ce;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 12px 12px 0 0;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    background: rgba(255,255,255,0.3);
}

.tab.active {
    background: var(--card-bg);
    color: var(--text);
}

.tab-content {
    background: var(--bg);
    border-radius: 0 16px 16px 16px;
    padding: 1.5rem;
    min-height: 500px;
}

.tab-pane {
    display: block;
}

.tab-pane.hidden {
    display: none;
}

.tab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .tab-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1rem;
}

.card:last-child {
    margin-bottom: 0;
}

.card-primary {
    border: 2px solid var(--primary);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.card-description {
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

/* Stats */
.stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stats-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.stats-card .card-header h2 {
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1.25rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.8);
    margin-top: 0.25rem;
}

/* Database Preview */
#db-preview {
    padding: 1rem 1.25rem;
}

.db-sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.db-sample-table th,
.db-sample-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.db-sample-table th {
    background: var(--bg);
    font-weight: 600;
}

.db-sample-table tr:hover {
    background: var(--bg);
}

.category-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Categories Stats */
#categories-stats {
    padding: 1rem 1.25rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.category-item {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-name {
    font-weight: 500;
}

.category-count {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Upload Zone */
.upload-zone {
    padding: 1.25rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    margin: 1rem;
    transition: all 0.2s ease;
    background: var(--bg);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.upload-zone-large {
    padding: 2.5rem 1.25rem;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.upload-icon {
    font-size: 2rem;
}

.upload-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* File List */
.file-list {
    padding: 0.5rem 1rem 1rem;
    max-height: 250px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0.4rem;
}

.file-item:last-child {
    margin-bottom: 0;
}

.file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.file-delete:hover {
    opacity: 1;
}

.empty-list {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    font-style: italic;
}

/* Processing Status */
.processing-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    margin: 0 1rem 1rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results */
.result-container {
    padding: 1rem 1.25rem;
}

.result-links {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-json {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-json label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-json textarea {
    width: 100%;
    height: 180px;
    padding: 0.75rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    resize: vertical;
}

.no-result {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* History */
.history-list {
    padding: 0.5rem 1rem 1rem;
    max-height: 350px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #e2e8f0;
}

.history-item.active {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid var(--primary);
}

.history-info {
    display: flex;
    flex-direction: column;
}

.history-file {
    font-weight: 500;
    font-size: 0.9rem;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.status-success {
    background: var(--conf-high);
    color: #166534;
}

.status-error {
    background: var(--conf-manual);
    color: #991b1b;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
    color: white;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.legend-title {
    font-weight: 600;
}

/* Utilities */
.hidden {
    display: none !important;
}

.loading {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.modal-icon {
    font-size: 1.5rem;
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin: 0;
}

#confirm-message {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}
