/* ===== IAGNOS Medical System Styles ===== */
:root {
    --primary: #1a5276;
    --primary-light: #2471a3;
    --primary-dark: #0e2f44;
    --secondary: #2ecc71;
    --accent: #3498db;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --bg-light: #f0f4f8;
    --bg-white: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --sidebar-width: 260px;
    --sidebar-collapsed: 60px;
    --border-color: #dce1e7;
    --shadow: 0 2px 12px rgba(26, 82, 118, 0.08);
    --shadow-lg: 0 4px 24px rgba(26, 82, 118, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg-light); color: var(--text-dark); margin: 0; padding: 0; }

/* ===== LOGIN PAGE ===== */
.login-container { display: flex; height: 100vh; width: 100vw; }
.login-left { flex: 1; overflow: hidden; position: relative; }
.login-bg-image { width: 100%; height: 100%; object-fit: cover; }
.login-right { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg-white); padding: 40px; }
.login-form-wrapper { width: 100%; max-width: 420px; }
.login-logos { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 24px; }
.login-logo { height: 80px; max-width: 200px; object-fit: contain; }
.login-title { text-align: center; color: var(--primary); font-weight: 700; font-size: 28px; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 30px; font-size: 14px; }
.btn-login { background: var(--primary); border: none; padding: 12px; font-size: 16px; font-weight: 600; border-radius: var(--radius-sm); transition: all .2s; }
.btn-login:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow); }

@media (max-width: 768px) {
    .login-container { flex-direction: column; }
    .login-left { height: 200px; flex: none; }
    .login-right { padding: 20px; }
}

/* ===== SIDEBAR ===== */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width); background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%); color: white; display: flex; flex-direction: column; z-index: 1000; box-shadow: 4px 0 16px rgba(0,0,0,0.15); overflow-y: auto; }
.sidebar-header { padding: 20px 16px; display: flex; align-items: center; justify-content: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { height: 40px; max-width: 100px; object-fit: contain; filter: brightness(1.1); }
.sidebar-menu { list-style: none; padding: 12px 0; margin: 0; flex: 1; }
.sidebar-menu li { margin: 2px 8px; }
.sidebar-menu a, .sidebar-menu .menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: rgba(255,255,255,0.8); text-decoration: none; border-radius: var(--radius-sm); transition: all .2s; cursor: pointer; font-size: 14px; }
.sidebar-menu a:hover, .sidebar-menu .menu-item:hover { background: rgba(255,255,255,0.12); color: white; }
.sidebar-menu a.active, .sidebar-menu .menu-item.active { background: rgba(255,255,255,0.2); color: white; font-weight: 600; }
.sidebar-menu .submenu { list-style: none; padding: 0 0 0 20px; margin: 0; display: none; }
.sidebar-menu .submenu.show { display: block; }
.sidebar-menu .submenu a, .sidebar-menu .submenu .menu-item { font-size: 13px; padding: 8px 14px; }
.sidebar-menu .menu-header { display: flex; justify-content: space-between; align-items: center; }
.sidebar-menu .menu-arrow { font-size: 12px; transition: transform .2s; }
.sidebar-menu .menu-arrow.rotated { transform: rotate(90deg); }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,0.9); font-size: 13px; }

/* ===== MAIN CONTENT ===== */
.main-content { margin-left: var(--sidebar-width); padding: 24px 30px; min-height: 100vh; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--primary); margin: 0; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== CARDS ===== */
.card { border: none; border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.card:hover { box-shadow: var(--shadow-lg); }
.card-header { background: var(--primary); color: white; border-radius: var(--radius) var(--radius) 0 0 !important; font-weight: 600; padding: 14px 20px; }

/* ===== STAT CARDS ===== */
.stat-card { border-radius: var(--radius); padding: 20px; color: white; position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 16px; top: 16px; font-size: 40px; opacity: 0.2; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label { font-size: 14px; opacity: 0.9; }
.stat-card .stat-sub { font-size: 12px; opacity: 0.75; margin-top: 8px; }
.stat-card.bg-medical-blue { background: linear-gradient(135deg, #1a5276, #2471a3); }
.stat-card.bg-medical-green { background: linear-gradient(135deg, #1e8449, #27ae60); }
.stat-card.bg-medical-purple { background: linear-gradient(135deg, #6c3483, #8e44ad); }
.stat-card.bg-medical-orange { background: linear-gradient(135deg, #d35400, #e67e22); }
.stat-card.bg-medical-red { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.stat-card.bg-medical-teal { background: linear-gradient(135deg, #117a65, #1abc9c); }

/* ===== TABLES ===== */
.table-container { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border-color); }
.table { margin: 0; }
.table thead th { background: var(--bg-light); color: var(--primary); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; border: none; padding: 12px 16px; }
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: var(--border-color); font-size: 14px; }
.table tbody tr:hover { background: #f8fafc; }
.action-icons { display: flex; gap: 8px; }
.action-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .2s; font-size: 16px; border: none; }
.action-icon.btn-info { background: #d1ecf7; color: #0c7abf; }
.action-icon.btn-success { background: #d4edda; color: #1e7e34; }
.action-icon.btn-warning { background: #fff3cd; color: #d39e00; }
.action-icon.btn-danger { background: #f8d7da; color: #c82333; }
.action-icon.btn-primary { background: #d6e0f0; color: var(--primary); }
.action-icon:hover { transform: scale(1.2); box-shadow: var(--shadow); }

/* ===== SEARCH & FILTERS ===== */
.search-box { position: relative; }
.search-box input { padding-left: 36px; border-radius: 20px; border: 1px solid var(--border-color); }
.search-box .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-panel { background: var(--bg-light); padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: none; }
.filter-panel.show { display: block; }

/* ===== FORMS ===== */
.form-section { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.form-section-title { font-size: 18px; font-weight: 600; color: var(--primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.form-label { font-weight: 500; color: var(--text-dark); font-size: 14px; }
.form-control, .form-select { border: 1.5px solid #adb5bd; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25); }
.form-check-input { border: 2px solid #6c757d; width: 1.2em; height: 1.2em; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ===== DUAL LISTBOX ===== */
.dual-listbox { display: flex; gap: 16px; align-items: stretch; }
.dual-listbox .listbox-panel { flex: 1; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: white; min-height: 300px; }
.dual-listbox .listbox-title { padding: 10px 14px; background: var(--bg-light); font-weight: 600; font-size: 13px; color: var(--primary); border-bottom: 1px solid var(--border-color); }
.dual-listbox .listbox-items { padding: 8px; min-height: 250px; }
.dual-listbox .listbox-item { padding: 8px 12px; margin: 4px 0; background: #f8fafc; border: 1px solid var(--border-color); border-radius: var(--radius-sm); cursor: grab; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.dual-listbox .listbox-item.locked { background: #e8f4fd; border-color: var(--accent); }
.dual-listbox .listbox-item.locked .lock-icon { color: var(--accent); }
.dual-listbox .listbox-item.sortable-ghost { opacity: 0.5; background: var(--accent); color: white; }
.dual-listbox .listbox-arrows { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.dual-listbox .listbox-arrows button { width: 40px; height: 40px; border-radius: 50%; }

/* ===== DIAGNOSIS DISPLAY ===== */
.diagnosis-container { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.health-status { padding: 16px 24px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 18px; font-weight: 700; text-align: center; }
.health-status.urgencia { background: linear-gradient(135deg, #fdedec, #f5b7b1); color: #c0392b; border: 2px solid #e74c3c; }
.health-status.semi_urgencia { background: linear-gradient(135deg, #fef9e7, #f9e79f); color: #b7950b; border: 2px solid #f39c12; }
.health-status.acompanhamento { background: linear-gradient(135deg, #eafaf1, #abebc6); color: #1e8449; border: 2px solid #27ae60; }
.health-status.sem_comorbidades { background: linear-gradient(135deg, #e8f8f5, #a3e4d7); color: #117a65; border: 2px solid #1abc9c; }

.diagnosis-section { margin-bottom: 24px; }
.diagnosis-section h4 { color: var(--primary); font-weight: 600; padding-bottom: 8px; border-bottom: 2px solid var(--bg-light); margin-bottom: 12px; }
.problem-item { padding: 12px; margin: 8px 0; border-radius: var(--radius-sm); border-left: 4px solid var(--accent); background: #f8fafc; }
.problem-item.alta { border-left-color: var(--danger); }
.problem-item.media { border-left-color: var(--warning); }
.problem-item.baixa { border-left-color: var(--success); }

.med-card { background: #f8fafc; border-radius: var(--radius-sm); padding: 16px; margin: 8px 0; border: 1px solid var(--border-color); }
.med-card .med-name { font-weight: 600; font-size: 16px; color: var(--primary); }
.med-card .med-lab { color: var(--text-muted); font-size: 13px; }
.med-card .med-detail { margin: 4px 0; font-size: 14px; }
.contra-indicator { color: var(--danger); }
.interaction-indicator { color: var(--warning); }

.study-item { padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.study-item:last-child { border: none; }

/* ===== CHART CONTAINERS ===== */
.chart-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.chart-card h5 { color: var(--primary); font-weight: 600; margin-bottom: 16px; }

/* ===== DOWNLOAD TABS ===== */
.download-tabs .nav-link { color: var(--primary); font-weight: 500; }
.download-tabs .nav-link.active { background: var(--primary); color: white; }

/* ===== LOADING ===== */
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.progress-counter { font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 12px; }
.progress-label { font-size: 14px; color: var(--text-muted); }

/* ===== TOAST ===== */
.toast { border-radius: var(--radius-sm); }

/* ===== BADGE STYLES ===== */
.badge-urgencia { background: var(--danger); }
.badge-semi_urgencia { background: var(--warning); }
.badge-acompanhamento { background: var(--success); }
.badge-sem_comorbidades { background: #1abc9c; }
.badge-enfermagem { background: #22B14C !important; color: #fff !important; }
.badge-medico { background: var(--primary) !important; color: #fff !important; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 16px; }

/* ===== RICH TEXT EDITOR ===== */
.ql-container { min-height: 200px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ql-toolbar { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 16px; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .3s; }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .dual-listbox { flex-direction: column; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }

/* ===== FILE UPLOAD ===== */
.upload-area { border: 2px dashed var(--border-color); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: all .2s; }
.upload-area:hover { border-color: var(--accent); background: #f8fafc; }
.upload-area.dragover { border-color: var(--accent); background: #e8f4fd; }
.upload-area i { font-size: 48px; color: var(--accent); display: block; margin-bottom: 12px; }
