/* ============================================
   Clinic Sales Assistant - Estilos principales
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a; color: #e2e8f0; height: 100vh; overflow: hidden;
}
.app {
    display: grid; grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto; height: 100vh; gap: 1px; background: #1e293b;
}

/* Header */
.header {
    grid-column: 1 / -1; background: #1e293b; padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #334155;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header h1 span { color: #3b82f6; }
.header-nav { display: flex; gap: 4px; }
.header-nav button {
    background: transparent; color: #94a3b8; border: 1px solid transparent;
    padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.header-nav button:hover { background: #334155; color: #e2e8f0; }
.header-nav button.active { background: #3b82f620; color: #60a5fa; border-color: #3b82f640; }

/* Clinic selector */
.clinic-selector { display: flex; align-items: center; gap: 8px; }
.clinic-selector label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.clinic-selector select {
    background: #0f172a; color: #e2e8f0; border: 1px solid #334155;
    padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
    cursor: pointer; appearance: auto;
}
.clinic-selector select:focus { outline: none; border-color: #3b82f6; }

/* Status Bar */
.status-bar {
    grid-column: 1 / -1; background: #0f172a; padding: 8px 24px;
    display: flex; gap: 16px; align-items: center; border-bottom: 1px solid #334155;
}
.status-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #94a3b8; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.status-dot.active { background: #22c55e; animation: pulse 2s infinite; }
.status-dot.error { background: #ef4444; }
.status-dot.warning { background: #f59e0b; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.phase-badge { margin-left: auto; background: #1e3a5f; color: #60a5fa; padding: 4px 14px; border-radius: 16px; font-size: 12px; font-weight: 600; }
.clinic-badge { background: #14532d; color: #4ade80; padding: 4px 12px; border-radius: 16px; font-size: 11px; font-weight: 600; }

/* Panels */
.panel { background: #0f172a; display: flex; flex-direction: column; overflow: hidden; }
.panel-header { padding: 10px 20px; background: #1e293b; border-bottom: 1px solid #334155; display: flex; align-items: center; justify-content: space-between; }
.panel-header h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; }
.panel-content { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* Transcript entries */
.transcript-entry { margin-bottom: 8px; padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.transcript-entry.agent { background: #172554; border-left: 3px solid #3b82f6; }
.transcript-entry.client { background: #14532d20; border-left: 3px solid #22c55e; }
.transcript-entry .speaker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.transcript-entry.agent .speaker { color: #60a5fa; }
.transcript-entry.client .speaker { color: #4ade80; }
.transcript-entry .time { font-size: 10px; color: #64748b; float: right; }
.transcript-entry.interim { opacity: 0.5; border-style: dashed; }

/* Suggestions */
.suggestion-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 16px; margin-bottom: 12px; transition: all 0.3s; }
.suggestion-card.latest { border-color: #22c55e; box-shadow: 0 0 20px #22c55e30; animation: slideIn 0.3s ease; }
.suggestion-card.latest::before { content: "RESPONDE AHORA"; display: block; font-size: 11px; font-weight: 700; color: #22c55e; margin-bottom: 8px; letter-spacing: 0.05em; }
.suggestion-card.thinking { border-color: #f59e0b; box-shadow: 0 0 15px #f59e0b20; }
.suggestion-card.thinking::before { content: "ANALIZANDO..."; display: block; font-size: 11px; font-weight: 700; color: #f59e0b; margin-bottom: 8px; letter-spacing: 0.05em; animation: pulse 1s infinite; }
@keyframes slideIn { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }
.suggestion-card .suggestion-text { font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.suggestion-card .suggestion-time { font-size: 11px; color: #64748b; margin-top: 8px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #475569; text-align: center; padding: 40px; }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

/* Setup Overlay */
.setup-overlay { position: fixed; inset: 0; background: #0f172aee; z-index: 100; display: flex; align-items: center; justify-content: center; }
.setup-card { background: #1e293b; border: 1px solid #334155; border-radius: 16px; padding: 40px; max-width: 520px; width: 90%; }
.setup-card h2 { font-size: 22px; margin-bottom: 8px; }
.setup-card p { color: #94a3b8; margin-bottom: 24px; line-height: 1.6; }
.setup-steps { list-style: none; margin-bottom: 24px; }
.setup-steps li { padding: 12px 16px; background: #0f172a; border-radius: 8px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; }
.setup-steps .step-icon { font-size: 20px; }
.setup-steps .step-text { font-size: 14px; }
.setup-steps .step-status { margin-left: auto; font-size: 12px; }
.setup-steps .step-status.ok { color: #22c55e; }
.setup-steps .step-status.missing { color: #f59e0b; }

.setup-clinic-select { width: 100%; background: #0f172a; color: #e2e8f0; border: 1px solid #334155; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; cursor: pointer; }
.setup-clinic-select:focus { outline: none; border-color: #3b82f6; }

.hidden { display: none !important; }

/* Controls */
.controls { grid-column: 1 / -1; background: #1e293b; padding: 10px 24px; display: flex; align-items: center; gap: 10px; border-top: 1px solid #334155; }
button { padding: 8px 18px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-start { background: #22c55e; color: white; font-size: 14px; padding: 10px 24px; }
.btn-start:hover { background: #16a34a; }
.btn-stop { background: #ef4444; color: white; }
.btn-stop:hover { background: #dc2626; }
.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:hover { background: #475569; }
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-danger-sm { background: #7f1d1d; color: #fca5a5; padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn-danger-sm:hover { background: #991b1b; }

.manual-input { flex: 1; display: flex; gap: 8px; }
.manual-input input { flex: 1; background: #0f172a; border: 1px solid #334155; color: #e2e8f0; padding: 8px 14px; border-radius: 8px; font-size: 13px; }
.manual-input input:focus { outline: none; border-color: #3b82f6; }
.manual-input input::placeholder { color: #475569; }

/* Volume Meters */
.volume-meter { width: 60px; height: 6px; background: #1e293b; border-radius: 3px; overflow: hidden; }
.volume-meter .level { height: 100%; background: #22c55e; border-radius: 3px; transition: width 0.1s; width: 0%; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Views */
.view-container { grid-column: 1 / -1; grid-row: 3 / 4; background: #0f172a; overflow-y: auto; padding: 24px; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.view-header h2 { font-size: 20px; font-weight: 600; }

/* Item cards */
.item-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 16px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; transition: border-color 0.2s; }
.item-card:hover { border-color: #475569; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.item-meta { font-size: 11px; color: #64748b; }
.item-preview { font-size: 12px; color: #94a3b8; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px; }
.item-actions { display: flex; gap: 6px; margin-left: 12px; flex-shrink: 0; }

/* Clinic cards */
.clinic-card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 20px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; transition: all 0.2s; cursor: pointer; }
.clinic-card:hover { border-color: #475569; }
.clinic-card.selected { border-color: #22c55e; box-shadow: 0 0 12px #22c55e20; }
.clinic-card .clinic-icon { font-size: 28px; margin-right: 16px; }
.clinic-card .clinic-info { flex: 1; }
.clinic-card .clinic-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.clinic-card .clinic-docs { font-size: 12px; color: #94a3b8; }

/* Upload area */
.upload-area { border: 2px dashed #334155; border-radius: 12px; padding: 30px; text-align: center; margin-bottom: 20px; cursor: pointer; transition: all 0.2s; }
.upload-area:hover { border-color: #3b82f6; background: #3b82f610; }
.upload-area.dragover { border-color: #22c55e; background: #22c55e10; }
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area .upload-text { font-size: 14px; color: #94a3b8; }
.upload-area .upload-hint { font-size: 11px; color: #64748b; margin-top: 6px; }
.upload-area input[type="file"] { display: none; }

/* New clinic input */
.new-clinic-row { display: flex; gap: 8px; margin-bottom: 20px; }
.new-clinic-row input { flex: 1; background: #0f172a; border: 1px solid #334155; color: #e2e8f0; padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.new-clinic-row input:focus { outline: none; border-color: #3b82f6; }
.new-clinic-row input::placeholder { color: #475569; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: #0f172aee; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-card { background: #1e293b; border: 1px solid #334155; border-radius: 16px; padding: 30px; max-width: 700px; width: 90%; max-height: 80vh; display: flex; flex-direction: column; }
.modal-card h3 { font-size: 18px; margin-bottom: 12px; }
.modal-content { flex: 1; overflow-y: auto; background: #0f172a; border-radius: 8px; padding: 16px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; font-family: 'SF Mono', 'Menlo', monospace; color: #cbd5e1; }
.modal-footer { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

.doc-count-pill { font-size: 10px; background: #22c55e30; color: #4ade80; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.section-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 12px; font-weight: 600; }

/* Generate button on client transcript entries */
.btn-generate {
    margin-top: 8px; background: #1e3a5f; color: #60a5fa; border: 1px solid #3b82f640;
    padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.btn-generate:hover { background: #2563eb; color: white; border-color: #3b82f6; }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-generate.generating { background: #78350f; color: #fbbf24; border-color: #f59e0b40; animation: pulse 1s infinite; }
.btn-generate.generated { background: #14532d; color: #4ade80; border-color: #22c55e40; cursor: default; }

/* Feedback buttons on suggestions */
.suggestion-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.feedback-buttons { display: flex; gap: 6px; }
.btn-feedback {
    background: #334155; border: 1px solid #47556960; padding: 4px 10px; border-radius: 6px;
    font-size: 14px; cursor: pointer; transition: all 0.2s; color: #94a3b8;
}
.btn-feedback:hover { background: #475569; }
.btn-feedback.good.selected { background: #14532d; border-color: #22c55e; }
.btn-feedback.bad.selected { background: #7f1d1d; border-color: #ef4444; }
.btn-feedback.edit { font-size: 12px; }
.feedback-label { font-size: 11px; margin-left: 8px; }

/* Correction input */
.correction-input { margin-top: 12px; border-top: 1px solid #334155; padding-top: 12px; }
.correction-textarea {
    width: 100%; background: #0f172a; color: #e2e8f0; border: 1px solid #3b82f6;
    border-radius: 8px; padding: 10px; font-size: 13px; line-height: 1.5; resize: vertical;
    font-family: inherit; min-height: 80px;
}
.correction-textarea:focus { outline: none; border-color: #60a5fa; }
.correction-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Training view */
.training-clinic-select { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.training-clinic-select label { font-size: 13px; color: #94a3b8; font-weight: 600; }
.training-clinic-select select {
    background: #0f172a; color: #e2e8f0; border: 1px solid #334155;
    padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.training-clinic-select select:focus { outline: none; border-color: #3b82f6; }

.training-field { margin-bottom: 16px; }
.training-field label {
    display: block; font-size: 12px; color: #94a3b8; text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 6px; font-weight: 600;
}
.training-field input, .training-field textarea {
    width: 100%; background: #1e293b; color: #e2e8f0; border: 1px solid #334155;
    border-radius: 8px; padding: 10px 14px; font-size: 14px; font-family: inherit;
    line-height: 1.5; resize: vertical;
}
.training-field input:focus, .training-field textarea:focus { outline: none; border-color: #3b82f6; }
.training-field input::placeholder, .training-field textarea::placeholder { color: #475569; }

.training-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.save-msg { font-size: 13px; font-weight: 600; }

/* Feedback stats */
.feedback-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-card {
    background: #1e293b; border: 1px solid #334155; border-radius: 10px;
    padding: 16px; text-align: center;
}
.stat-card.good { border-color: #22c55e40; }
.stat-card.bad { border-color: #ef444440; }
.stat-card.corrected { border-color: #3b82f640; }
.stat-number { font-size: 28px; font-weight: 700; color: #e2e8f0; }
.stat-label { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.feedback-bar { width: 100%; height: 8px; background: #7f1d1d; border-radius: 4px; overflow: hidden; }
.feedback-bar-fill { height: 100%; background: #22c55e; border-radius: 4px; transition: width 0.5s; }

@media (max-width: 800px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr 1fr auto; }
    .header { flex-wrap: wrap; gap: 8px; }
    .feedback-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
