/* ============================================================
   RGMS - Research Group Management System  |  Application styles
   ============================================================ */
:root {
  --rg-primary: #1f3a5f;
  --rg-primary-dark: #14263f;
  --rg-accent: #2e7d9a;
  --rg-sidebar-width: 260px;
  --rg-topbar-height: 60px;
  --rg-bg: #f4f6f9;
  --bs-primary: #1f3a5f;
  --bs-primary-rgb: 31, 58, 95;
  --bs-link-color: #1f3a5f;
  --bs-link-hover-color: #14263f;
}
html, body { height: 100%; }
body { background: var(--rg-bg); font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; font-size: .925rem; color: #2b2f33; }

.btn-primary { --bs-btn-bg: var(--rg-primary); --bs-btn-border-color: var(--rg-primary); --bs-btn-hover-bg: var(--rg-primary-dark); --bs-btn-hover-border-color: var(--rg-primary-dark); --bs-btn-active-bg: var(--rg-primary-dark); --bs-btn-active-border-color: var(--rg-primary-dark); --bs-btn-disabled-bg: var(--rg-primary); --bs-btn-disabled-border-color: var(--rg-primary); }
.btn-outline-primary { --bs-btn-color: var(--rg-primary); --bs-btn-border-color: var(--rg-primary); --bs-btn-hover-bg: var(--rg-primary); --bs-btn-hover-border-color: var(--rg-primary); --bs-btn-active-bg: var(--rg-primary); --bs-btn-active-border-color: var(--rg-primary); }
.bg-primary { background-color: var(--rg-primary) !important; }
.text-primary { color: var(--rg-primary) !important; }
.bg-indigo { background-color: #5b4bdb !important; color: #fff; }
.bg-teal { background-color: #0f8b8d !important; color: #fff; }
.nav-tabs .nav-link.active { color: var(--rg-primary); font-weight: 600; }
.form-control:focus, .form-select:focus { border-color: var(--rg-accent); box-shadow: 0 0 0 .2rem rgba(46,125,154,.2); }
.page-link { color: var(--rg-primary); }
.page-item.active .page-link { background: var(--rg-primary); border-color: var(--rg-primary); }

/* Layout ------------------------------------------------------ */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--rg-sidebar-width); background: linear-gradient(180deg, var(--rg-primary) 0%, var(--rg-primary-dark) 100%);
  color: #fff; position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040; display: flex; flex-direction: column;
  transition: transform .25s ease; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand a { color: #fff; }
.brand-icon { font-size: 1.6rem; margin-right: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 600; font-size: .95rem; }
.brand-sub { font-size: .72rem; color: rgba(255,255,255,.65); }
.sidebar-role { padding: 10px 18px 4px; }
.sidebar-nav { padding: 8px 10px 20px; flex: 1; }
.sidebar-nav .nav-heading { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.5); padding: 14px 10px 4px; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); padding: 9px 12px; border-radius: 8px; font-size: .9rem; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 10px 18px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }

.main-content { flex: 1; margin-left: var(--rg-sidebar-width); display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--rg-topbar-height); background: #fff; border-bottom: 1px solid #e3e6ea; display: flex; align-items: center; padding: 0 20px; position: sticky; top: 0; z-index: 1020; gap: 12px; }
.topbar-search { position: relative; width: 300px; }
.topbar-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #8a94a0; font-size: .85rem; }
.topbar-search input { padding-left: 30px; border-radius: 20px; background: #f4f6f9; border-color: #e3e6ea; }
.page-content { padding: 20px 24px; flex: 1; }
.app-footer { padding: 10px 24px; font-size: .78rem; color: #8a94a0; border-top: 1px solid #e3e6ea; display: flex; background: #fff; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-left: 0; }
  .page-content { padding: 14px 14px; }
}

/* Components -------------------------------------------------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-header h1 { font-size: 1.35rem; font-weight: 600; margin: 0; color: var(--rg-primary); }
.card { border: 1px solid #e3e6ea; border-radius: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 600; }
.stat-card { border-left: 4px solid var(--rg-primary); }
.stat-card .stat-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: rgba(31,58,95,.08); color: var(--rg-primary); }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; color: #6c757d; text-transform: uppercase; letter-spacing: .04em; }
.stat-card.success { border-left-color: #198754; } .stat-card.success .stat-icon { background: rgba(25,135,84,.1); color: #198754; }
.stat-card.warning { border-left-color: #ffc107; } .stat-card.warning .stat-icon { background: rgba(255,193,7,.15); color: #b98900; }
.stat-card.danger { border-left-color: #dc3545; } .stat-card.danger .stat-icon { background: rgba(220,53,69,.1); color: #dc3545; }
.stat-card.info { border-left-color: #0dcaf0; } .stat-card.info .stat-icon { background: rgba(13,202,240,.12); color: #0a8ba3; }
.stat-card.accent { border-left-color: var(--rg-accent); } .stat-card.accent .stat-icon { background: rgba(46,125,154,.12); color: var(--rg-accent); }

.status-badge { font-size: .68rem; letter-spacing: .04em; font-weight: 600; padding: .38em .7em; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--rg-primary); color: #fff; font-weight: 600; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-md { width: 40px; height: 40px; font-size: .9rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

.table { font-size: .875rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; background: #f8f9fb; border-bottom: 1px solid #e3e6ea; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f6f9fc; }
.notification-menu { width: 340px; max-width: 92vw; padding: 0; }
.notification-item { white-space: normal; padding: 8px 14px; border-bottom: 1px solid #f0f2f4; }
.notification-item.unread { background: #f0f5fb; }
.dl-info dt { font-size: .74rem; text-transform: uppercase; color: #6c757d; letter-spacing: .04em; font-weight: 600; margin-bottom: 2px; }
.dl-info dd { margin-bottom: 12px; }

/* Timeline ------------------------------------------------------ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: #e3e6ea; }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ""; position: absolute; left: -23px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--rg-accent); border: 2px solid #fff; box-shadow: 0 0 0 2px #e3e6ea; }
.timeline-date { font-size: .74rem; color: #6c757d; }

/* Workflow stepper --------------------------------------------- */
.workflow-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.workflow-step { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: .78rem; background: #eef1f5; color: #6c757d; }
.workflow-step.done { background: rgba(25,135,84,.12); color: #198754; }
.workflow-step.current { background: rgba(31,58,95,.12); color: var(--rg-primary); font-weight: 600; }
.workflow-step.rejected { background: rgba(220,53,69,.12); color: #dc3545; }

/* Position comparison boxes ----------------------------------- */
.position-box { border: 1px solid #e3e6ea; border-radius: 8px; padding: 10px 14px; background: #fff; }
.position-box .label { font-size: .72rem; text-transform: uppercase; color: #6c757d; letter-spacing: .04em; }
.position-box .value { font-weight: 600; font-size: 1rem; }

/* CRediT checkboxes ------------------------------------------- */
.credit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }

/* Mobile cards for tables ------------------------------------- */
@media (max-width: 767.98px) {
  .table-mobile-cards thead { display: none; }
  .table-mobile-cards tbody tr { display: block; border: 1px solid #e3e6ea; border-radius: 8px; margin-bottom: 10px; background: #fff; padding: 6px 0; }
  .table-mobile-cards tbody td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border: 0; padding: 6px 12px; text-align: right; }
  .table-mobile-cards tbody td::before { content: attr(data-label); font-weight: 600; color: #6c757d; font-size: .75rem; text-transform: uppercase; text-align: left; flex-shrink: 0; }
  .table-mobile-cards tbody td.actions { justify-content: flex-end; }
  .table-mobile-cards tbody td.actions::before { content: ""; }
}

/* Auth pages --------------------------------------------------- */
.auth-body { background: var(--rg-bg); }
.auth-wrapper { min-height: 100vh; display: flex; }
.auth-panel-left { flex: 1; background: linear-gradient(160deg, var(--rg-primary) 0%, var(--rg-accent) 100%); color: #fff; padding: 60px; align-items: center; }
.auth-panel-right { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px 16px; }
.auth-card { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(16,24,40,.08); padding: 36px; width: 100%; max-width: 440px; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 20px; }
.auth-heading { font-size: 2rem; font-weight: 700; }
.auth-tagline { font-size: 1.05rem; color: rgba(255,255,255,.85); margin-bottom: 30px; }
.auth-features { list-style: none; padding: 0; }
.auth-features li { padding: 6px 0; display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.9); }
.demo-accounts { font-size: .8rem; }
.demo-accounts code { cursor: pointer; }

.progress { height: 8px; }
.required::after { content: " *"; color: #dc3545; }
.text-break-all { word-break: break-all; }
.small-caps { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #6c757d; font-weight: 600; }
.chart-box { position: relative; height: 260px; }
.doc-icon { font-size: 1.6rem; }
.hover-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.1); transform: translateY(-1px); transition: all .15s ease; }
.copy-box { font-family: Consolas, Menlo, monospace; font-size: .8rem; background: #f8f9fb; border: 1px solid #e3e6ea; border-radius: 8px; padding: 12px; white-space: pre-wrap; max-height: 320px; overflow: auto; }
@media print { .sidebar, .topbar, .app-footer, .btn, .no-print { display: none !important; } .main-content { margin: 0; } }
