/* ============================================================
   Orar — modern design system
   ============================================================ */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;

  --sidebar-bg: #0f172a;
  --sidebar-fg: #94a3b8;
  --sidebar-fg-hover: #e2e8f0;
  --sidebar-active-bg: rgba(99, 102, 241, 0.15);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.main-area {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  --bs-offcanvas-width: 260px;
}

@media (min-width: 992px) {
  .sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
  }
}

.sidebar-body {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
}

.sidebar-brand,
.offcanvas-header .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  padding: 0.25rem 0.6rem 1.25rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.45);
}

.offcanvas-header { background: var(--sidebar-bg); }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-fg);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.sidebar-link:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--sidebar-fg-hover);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  box-shadow: inset 3px 0 0 #6366f1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1.25rem 0.8rem 0.25rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #475569;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  margin-top: 1.5rem;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 60px;
  padding: 0 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
}

.topbar-title i { color: var(--primary); }

/* ---------- Content ---------- */
.content { padding: 1.75rem; }

.content-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  max-width: 1180px;
}

.content-inner > h1:first-child,
.content-inner > h1 { font-weight: 800; letter-spacing: -0.02em; font-size: 1.6rem; line-height: 1.3; }
.content-inner h4 { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; line-height: 1.35; }
.content-inner h5 { font-weight: 700; font-size: 1rem; line-height: 1.35; }

/* Avoid diacritics (ă, ț, î) being visually clipped in headings/controls. */
h1, h2, h3, h4, h5, h6 { padding-bottom: 0.05em; }
.form-select, .form-control { line-height: 1.5; }
.form-select { background-position: right 0.6rem center; }

/* section heading accent for h4 blocks */
.content-inner h4 {
  position: relative;
  padding-left: 0.85rem;
  margin-top: 1.75rem;
}
.content-inner h4::before {
  content: "";
  position: absolute;
  left: 0; top: 0.15rem; bottom: 0.15rem;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #6366f1, #4f46e5);
}

.lead { color: var(--muted); font-size: 1.05rem; }
.text-muted { color: var(--muted) !important; }

code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  color: #be185d;
  font-size: 0.85em;
}

hr { color: var(--border-strong); opacity: 1; }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  border-color: var(--border);
  margin-bottom: 0.5rem;
}

.content-inner .table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.7rem 0.85rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:first-child td { border-top: none; }

.table.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: var(--surface-muted);
}

.table tbody tr { transition: background-color 0.12s; }
.table-hover tbody tr:hover > *,
.content-inner .table tbody tr:hover > * { background-color: var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn {
  font-weight: 600;
  border-radius: 9px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

.btn-outline-primary { color: var(--primary); border-color: var(--border-strong); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

.btn-outline-danger { border-color: var(--border-strong); }

.btn-light {
  background: var(--surface);
  border: 1px solid var(--border);
}
.btn-light:hover { background: var(--surface-muted); }

/* ---------- Forms ---------- */
.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  border-radius: 9px;
  border-color: var(--border-strong);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}
.form-check-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ---------- Alerts ---------- */
.alert {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}
.alert .btn-close { margin-left: auto; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: var(--primary-soft); border-color: #c7d2fe; color: #3730a3; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- Accordion ---------- */
.accordion {
  --bs-accordion-border-color: var(--border);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.accordion-button {
  font-weight: 600;
  background: var(--surface-muted);
}
.accordion-button:not(.collapsed) {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- Dashboard cards (home) ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
}

.dash-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.dash-card h6 { font-weight: 700; margin: 0; font-size: 1rem; }
.dash-card p { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.dash-card .dash-arrow {
  margin-top: auto;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---------- Schedule grid ---------- */
.schedule-table { font-size: 0.85rem; }
.schedule-table th,
.schedule-table td {
  vertical-align: middle;
  white-space: pre-line;
}

.schedule-table thead th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
}

.schedule-table td.curs {
  background-color: var(--primary-soft);
  font-weight: 600;
  text-align: center;
  color: #3730a3;
}

.schedule-table td.seminar { text-align: left; }

/* ---------- Availability grid ---------- */
.availability-grid th,
.availability-grid td {
  text-align: center;
  vertical-align: middle;
}
.availability-grid thead th { font-size: 0.7rem; }
.availability-grid td input { transform: scale(1.25); cursor: pointer; }

/* ---------- Misc ---------- */
.badge-soft {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
}

/* ---------- Identity card (preferinte §1) ---------- */
.identity-card {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fbfcff, #f4f6ff);
}

.identity-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.identity-body { flex: 1 1 auto; min-width: 0; }

.identity-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.identity-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.identity-select { flex: 1 1 16rem; min-width: 12rem; }

/* segmented control built from .btn-check radios */
.segmented {
  display: inline-flex;
  background: #e9ecf5;
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
}
.segmented .btn {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  box-shadow: none;
}
.segmented .btn-check:checked + .btn {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.segmented .btn:hover { color: var(--primary); transform: none; }

/* ---------- Validation report (vizualizare) ---------- */
.report-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.report-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  font-weight: 700;
  font-size: 0.98rem;
}
.report-head i { font-size: 1.25rem; }
.report-ok .report-head { background: #ecfdf5; color: #065f46; border-bottom: 1px solid #a7f3d0; }
.report-fail .report-head { background: #fef2f2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.report-warn .report-head { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.report-warn .report-list li.fail i { color: #d97706; }

.report-list { list-style: none; margin: 0; padding: 0.4rem 0; }
.report-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 1.1rem;
  flex-wrap: wrap;
}
.report-list li + li { border-top: 1px solid var(--surface-muted); }
.report-list li i { font-size: 0.95rem; position: relative; top: 2px; }
.report-list li.ok i { color: #16a34a; }
.report-list li.fail i { color: #dc2626; }
.report-label { font-weight: 600; }
.report-detail { color: var(--muted); font-size: 0.88rem; flex: 1 1 18rem; }

/* ---------- Schedule day separation ---------- */
.schedule-table .day-name {
  background: #eef1fb;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  color: #312e81;
  white-space: nowrap;
  letter-spacing: 0.02em;
  width: 5.5rem;
}
.schedule-table tbody tr.day-block-0 td { background-color: #ffffff; }
.schedule-table tbody tr.day-block-1 td { background-color: #f8fafc; }
.schedule-table tbody tr.day-block-1 td.curs { background-color: var(--primary-soft); }
.schedule-table tbody tr.day-start > * { border-top: 2px solid var(--primary) !important; }
.schedule-table .ora-cell { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.schedule-table .tip-cell { font-weight: 700; color: var(--muted); }

/* keep availability grids compact */
.availability-grid { font-size: 0.82rem; }
.availability-grid thead th { line-height: 1.25; }

/* ---------- Prominent "minimize gaps" toggle ---------- */
.gap-toggle {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.25rem;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  background: var(--primary-soft);
  cursor: pointer;
  width: 100%;
}
.gap-toggle .form-check-input {
  width: 3.2rem;
  height: 1.6rem;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}
.gap-toggle-title { display: block; font-weight: 700; font-size: 1.02rem; color: #312e81; }
.gap-toggle-sub { display: block; color: #4f46e5; font-size: 0.85rem; }

/* ---------- Orar tabs + centered generate ---------- */
.nav-tabs { border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.nav-tabs .nav-link {
  border: none;
  font-weight: 600;
  color: var(--muted);
  padding: 0.6rem 1.1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.nav-tabs .nav-link:hover { color: var(--primary); border-color: transparent; }
.nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-bottom: 2px solid var(--primary);
}
.tab-badge {
  background: #fee2e2; color: #b91c1c;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  padding: 0.05rem 0.5rem; margin-left: 0.4rem;
}
.btn-generate { padding: 0.85rem 2.5rem; font-size: 1.1rem; }

.gen-time-hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; }

.gen-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.gen-overlay.active { display: flex; }
.gen-overlay-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem 2.75rem;
  text-align: center;
  max-width: 22rem;
}
.gen-spinner {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1.1rem;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: gen-spin 0.8s linear infinite;
}
@keyframes gen-spin {
  to { transform: rotate(360deg); }
}
.gen-overlay-title { font-weight: 600; margin-bottom: 0.35rem; }
.gen-overlay-hint { color: var(--muted); font-size: 0.9rem; }

/* ---------- Wider dropdowns so long labels fit ---------- */
.select-wide  { min-width: 17rem; }
.select-xwide { min-width: 30rem; max-width: 100%; }
@media (max-width: 575px) {
  .select-wide, .select-xwide { min-width: 100%; }
}

/* ---------- Free day highlight (schedule grid) ---------- */
.schedule-table tbody tr.day-free td,
.schedule-table tbody tr.day-free td.curs { background-color: #eceff3 !important; color: #94a3b8; }
.schedule-table tbody tr.day-free .day-name { background-color: #e2e6ec !important; color: #8a93a3; }
.legend-free {
  display: inline-block;
  width: 0.9rem; height: 0.9rem;
  vertical-align: -1px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: #eceff3;
  margin-right: 0.3rem;
}

/* ---------- Rooms availability grid (Orar › Săli) ---------- */
.rooms-grid .room-name {
  background: #eef1fb;
  color: #312e81;
  white-space: nowrap;
  font-weight: 700;
  vertical-align: middle;
}
.rooms-grid td { font-size: 0.78rem; vertical-align: middle; min-width: 8rem; }
.rooms-grid td.room-free { background: #eceff3; color: #94a3b8; }
.rooms-grid td.room-busy { background: #ffffff; }

/* ---------- Hard-constraint list (home) ---------- */
.hc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.hc-item {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}
.hc-code {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  letter-spacing: 0.02em;
}
.hc-desc { font-size: 0.88rem; color: var(--text); line-height: 1.4; }

/* ============================================================
   Responsive / mobile (most users open this on a phone)
   ============================================================ */

/* Smooth touch scrolling for any horizontally-scrollable table */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* Tablets and below: trim the chrome a bit */
@media (max-width: 991.98px) {
  .topbar { padding: 0 0.9rem; }
  .content { padding: 1rem; }
}

/* Phones */
@media (max-width: 767.98px) {
  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  .form-control, .form-select { font-size: 16px; }

  .content { padding: 0.75rem; }
  .content-inner { padding: 1.05rem 0.9rem; border-radius: 12px; }
  .content-inner > h1,
  .content-inner > h1:first-child { font-size: 1.3rem; }
  .content-inner h4 { font-size: 1rem; margin-top: 1.25rem; }
  .lead { font-size: 0.96rem; }

  .topbar { padding: 0 0.75rem; }
  .topbar-title { font-size: 0.95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Data-entry forms: each field on its own full-width row instead of
     overflowing off-screen */
  .content-inner form.row.g-2 > .col-auto,
  .content-inner form.row.g-3 > .col-auto { flex: 0 0 100%; max-width: 100%; }
  .content-inner form.row .col-auto .form-control,
  .content-inner form.row .col-auto .form-select { width: 100%; }
  .content-inner form.row .col-auto [style*="min-width"] { min-width: 0 !important; }
  .content-inner form.row .col-auto [style*="max-width"] { max-width: 100% !important; }
  /* Inline edit forms (rename, etc.) wrap rather than overflow */
  .content-inner form.d-flex { flex-wrap: wrap; }

  /* Tables: compact; horizontal scroll handled by the .table-responsive wrap */
  .content-inner .table { font-size: 0.84rem; }
  .table thead th { padding: 0.5rem 0.55rem; font-size: 0.68rem; }
  .table tbody td { padding: 0.45rem 0.55rem; }

  /* Identity card (Preferințe) stacks vertically */
  .identity-card { flex-direction: column; align-items: stretch; gap: 0.85rem; padding: 1rem; }
  .identity-avatar { width: 48px; height: 48px; font-size: 1.1rem; }
  .identity-name { font-size: 1.15rem; }
  .identity-form { width: 100%; }
  .identity-select { flex-basis: 100%; min-width: 0; }

  /* Segmented view-toggle wraps to fit a narrow screen */
  .segmented { display: flex; flex-wrap: wrap; width: 100%; }
  .segmented .btn { flex: 1 1 auto; padding: 0.45rem 0.55rem; font-size: 0.82rem; }

  /* Big generate button spans the width */
  .btn-generate { width: 100%; padding: 0.8rem 1rem; font-size: 1rem; }
  .gen-overlay-card { padding: 1.75rem 1.5rem; max-width: 90vw; }

  /* Constraint report: detail drops under its label */
  .report-detail { flex-basis: 100%; }
  .report-head { font-size: 0.92rem; }

  /* Schedule + availability grids: tighter so more fits before scrolling */
  .schedule-table { font-size: 0.7rem; }
  .schedule-table th, .schedule-table td { padding: 0.35rem 0.4rem; }
  .schedule-table .day-name { width: auto; }
  .availability-grid { font-size: 0.72rem; }
  .availability-grid td input { transform: scale(1.1); }
  .rooms-grid td { min-width: 6rem; }

  /* Card grids collapse to a single column */
  .dash-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .hc-grid { grid-template-columns: 1fr; }

  .nav-tabs .nav-link { padding: 0.5rem 0.7rem; font-size: 0.9rem; }
}
