/* ==========================================
   Dr. Billetes - Bolivia Theme
   Colores: Rojo #D52B1E, Amarillo #F9E300, Verde #007934
   ========================================== */

:root {
    --red: #D52B1E;
    --red-dark: #B01F15;
    --yellow: #F9E300;
    --yellow-dark: #D4C200;
    --green: #007934;
    --green-dark: #005A27;
    --bg: #0F1117;
    --bg-card: #1A1D27;
    --bg-card-hover: #222632;
    --bg-input: #13151D;
    --border: #2A2E3B;
    --border-light: #3A3F50;
    --text: #E8E9ED;
    --text-secondary: #9498A6;
    --text-muted: #6B7080;
    --danger: #EF4444;
    --success: #22C55E;
    --warning: #F59E0B;
    --info: #3B82F6;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-card) 0%, #1E2130 100%);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    color: var(--yellow);
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--yellow) 0%, var(--red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(213, 43, 30, 0.15);
    color: var(--red);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(213, 43, 30, 0.3);
}

.badge-dot {
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-card);
    padding: 0.35rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.tab:hover {
    color: var(--text);
    background: var(--bg-card-hover);
}

.tab.active {
    color: var(--bg);
    background: var(--yellow);
    font-weight: 600;
}

.tab.active svg {
    stroke: var(--bg);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* Section Titles */
.section-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Layout */
.scan-layout, .manual-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.training-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
}

/* Camera */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--bg-input);
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px dashed var(--border);
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.camera-overlay.hidden { display: none; }

.camera-frame {
    position: absolute;
    inset: 12%;
    pointer-events: none;
    display: none;
}

.camera-frame.active { display: block; }

.frame-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--yellow);
    border-style: solid;
}

.frame-corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; }
.frame-corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; }
.frame-corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.frame-corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

.camera-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--info);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: #2563EB; }

.btn-success {
    background: var(--green);
    color: white;
}
.btn-success:hover:not(:disabled) { background: var(--green-dark); }

.btn-scan {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
    color: white;
    padding: 0.85rem 2rem;
    font-size: 1rem;
}
.btn-scan:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(213, 43, 30, 0.4);
}

.btn-train {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
    color: white;
    padding: 0.85rem 2rem;
    font-size: 1rem;
}
.btn-train:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 121, 52, 0.4);
}

.btn-block {
    width: 100%;
    margin-top: 1rem;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--yellow);
    background: rgba(249, 227, 0, 0.05);
}

.upload-hint {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Image Preview */
.image-preview {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 1rem;
    border: 2px solid var(--border);
}

.image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    background: var(--bg-input);
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px rgba(249, 227, 0, 0.15);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Denomination Selector */
.denomination-selector {
    display: flex;
    gap: 0.75rem;
}

.denom-btn {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-align: center;
}

.denom-btn:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.denom-btn.active {
    border-color: var(--yellow);
    background: rgba(249, 227, 0, 0.1);
}

.denom-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--yellow);
}

/* Results Panel */
.results-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-height: 400px;
    position: sticky;
    top: 100px;
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 350px;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

/* Result Card */
.result-card {
    animation: slideUp 0.5s ease;
}

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

.result-verdict {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.result-verdict.legal {
    background: rgba(34, 197, 94, 0.1);
    border: 2px solid rgba(34, 197, 94, 0.3);
}

.result-verdict.ilegal {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    animation: pulseRed 1.5s ease-in-out 3;
}

.result-verdict.sospechoso {
    background: rgba(245, 158, 11, 0.1);
    border: 2px solid rgba(245, 158, 11, 0.3);
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 30px rgba(239, 68, 68, 0.3); }
}

.verdict-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.verdict-text {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.verdict-text.legal { color: var(--success); }
.verdict-text.ilegal { color: var(--danger); }
.verdict-text.sospechoso { color: var(--warning); }

.result-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-value {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.confidence-bar {
    width: 100px;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Model Info Card */
.model-info-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.info-row:last-child { border-bottom: none; }

.info-label { color: var(--text-secondary); }
.info-value { font-weight: 600; color: var(--text); }

.params-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Training Progress */
.training-progress {
    margin-top: 1rem;
    text-align: center;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--yellow));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Charts */
.training-charts {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--yellow);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Database Tables */
.db-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.db-table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-title {
    padding: 0.85rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.table-title.bs50 { background: linear-gradient(135deg, var(--red), var(--red-dark)); }
.table-title.bs20 { background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.table-title.bs10 { background: linear-gradient(135deg, var(--info), #1D4ED8); }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: rgba(255,255,255,0.05);
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.data-table td {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

.footer-tech {
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 900px) {
    .scan-layout, .manual-layout, .training-layout {
        grid-template-columns: 1fr;
    }

    .results-panel {
        position: static;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-content {
        padding: 1rem;
    }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.78rem;
    }

    .db-tables {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 500px) {
    .denomination-selector {
        flex-direction: column;
    }

    .camera-controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
