:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --warning: #eab308;
    
    --risk-red: #ef4444;
    --risk-orange: #f97316;
    --risk-yellow: #eab308;
    --risk-green: #22c55e;
    --risk-blue: #3b82f6;

    --border: #334155;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body { background: var(--bg-dark); color: var(--text-main); line-height: 1.5; }
.hidden { display: none !important; }
.active { display: block; }
.mt-2 { margin-top: 10px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 10px; }

#app-container { max-width: 1200px; margin: 0 auto; height: 100vh; display: flex; flex-direction: column; }

/* Login */
.login-wrapper { max-width: 400px; margin: 100px auto; text-align: center; background: var(--bg-panel); padding: 30px; border-radius: var(--radius); }
.logo-login { max-width: 150px; margin-bottom: 20px; }

/* Header */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: var(--bg-panel); border-bottom: 1px solid var(--border); }
.header-left { display: flex; align-items: center; gap: 10px; }
.logo-header { height: 40px; }
.status-online { color: var(--success); font-weight: bold; margin-right: 15px; }
.btn-icon { background: none; border: none; color: var(--text-main); font-size: 16px; cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* Dashboard Grid */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; padding: 20px; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; padding: 0 20px; text-align: center; }
.metric-card { padding: 20px; border-radius: var(--radius); }
.metric-card h3 { font-size: 32px; }
.bg-blue { background: #1e3a8a; }
.bg-orange { background: #9a3412; }
.bg-green { background: #14532d; }

/* Buttons & Inputs */
.btn-giant { width: 100%; padding: 20px; font-size: 18px; font-weight: bold; border: none; border-radius: var(--radius); cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; color: white; transition: 0.2s; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-hover); }
.btn-secondary { background: var(--border); }
.btn-secondary:hover { background: #475569; }

.input-large, .input-giant { width: 100%; padding: 15px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-dark); color: white; font-size: 16px; }
.input-giant { font-size: 20px; padding: 20px; }
textarea.input-large { resize: vertical; }

/* Screens & Lists */
.sub-screen { padding: 20px; flex: 1; overflow-y: auto; }
.screen-header { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }

.list-container { background: var(--bg-panel); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.list-item { padding: 15px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.list-item:hover { background: #334155; }
.list-item:last-child { border-bottom: none; }

/* TABS (Stepper) */
.attendance-header { background: var(--bg-panel); padding: 15px; border-radius: var(--radius) var(--radius) 0 0; display: flex; justify-content: space-between; align-items: center; }
.pat-info-top { text-align: right; }
.tabs { display: flex; width: 100%; background: #0f172a; border-bottom: 2px solid var(--border); }
.tab-btn { flex: 1; padding: 15px; background: none; border: none; color: var(--text-muted); font-size: 16px; font-weight: bold; cursor: pointer; }
.tab-btn.active { color: var(--primary); border-bottom: 4px solid var(--primary); background: var(--bg-panel); }
.tab-pane { display: none; padding: 20px; background: var(--bg-panel); border-radius: 0 0 var(--radius) var(--radius); min-height: 400px; }
.tab-pane.active { display: block; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* Risk Selector */
.risk-selector, .alta-selector { display: flex; width: 100%; gap: 5px; }
.risk-btn, .alta-btn { flex: 1; padding: 20px 5px; text-align: center; cursor: pointer; color: white; font-weight: bold; border-radius: var(--radius); font-size: 14px; opacity: 0.7; transition: 0.2s; }
.risk-btn input, .alta-btn input { display: none; }
.risk-btn:has(input:checked), .alta-btn:has(input:checked) { opacity: 1; outline: 3px solid white; transform: scale(1.02); }

.bg-red { background: var(--risk-red); }
.bg-orange { background: var(--risk-orange); }
.bg-yellow { background: var(--risk-yellow); color: black !important; }
.bg-green { background: var(--risk-green); }
.bg-blue { background: var(--risk-blue); }
.alta-btn { background: var(--border); }
.alta-btn:has(input:checked) { background: var(--primary); }

/* Medico Protocolos */
.medico-layout, .medicacao-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; }
.protocolos { display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--border); padding-right: 20px; }
.btn-protocol { padding: 15px; background: var(--border); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-weight: bold; text-align: left; }
.btn-protocol:hover { background: var(--primary); }
.campos-medico label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: bold; color: var(--text-muted); }

/* Medicacao PDV */
.estoque-lista { border-right: 1px solid var(--border); padding-right: 20px; height: 100%; overflow-y: auto; }
.prescricao-area { padding-left: 10px; }

/* Toast */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; }
.toast { background: var(--bg-panel); color: white; padding: 15px 25px; margin-top: 10px; border-radius: var(--radius); box-shadow: 0 4px 6px rgba(0,0,0,0.3); border-left: 5px solid var(--primary); animation: slideIn 0.3s ease; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

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

/* Impressão */
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; color: black; background: white; padding: 20px; }
    .print-header { text-align: center; border-bottom: 2px solid black; padding-bottom: 10px; margin-bottom: 20px; }
    .print-header img { max-width: 100px; }
    .print-section { margin-bottom: 20px; border: 1px solid #ccc; padding: 15px; border-radius: 4px; }
    .print-signatures { margin-top: 50px; display: flex; justify-content: space-around; text-align: center; }
    .signature-line { border-top: 1px solid black; width: 250px; padding-top: 5px; }
}

@media (max-width: 768px) {
    .medico-layout, .medicacao-layout { grid-template-columns: 1fr; }
    .protocolos, .estoque-lista { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 20px; margin-bottom: 20px; }
    .tab-btn { font-size: 12px; padding: 10px 5px; }
    .risk-btn { padding: 15px 2px; font-size: 11px; }
}
