/* =====================================================================
   Erp iTav - tema peste CoreUI 5 (local, fara CDN)
   ---------------------------------------------------------------------
   Paleta din proiectul B (verde / antracit / alb), cu doua roluri:
     antracit (--itav-ink)  = structura: meniul lateral, titluri
     verde    (--itav-brand) = actiune: butoane, linkuri, focus, element activ
   Verdele de pe butoane este un ton mai inchis (#15803d) decat accentul
   (#22c55e), ca textul alb de pe el sa ramana usor de citit.
   Tema intunecata: CoreUI o comuta prin atributul data-coreui-theme="dark"
   pe <html>; mai jos redefinim doar culorile noastre pentru ea.
   ===================================================================== */

:root,
[data-coreui-theme=light] {
  --itav-ink: #1a1d29;
  --itav-ink-2: #232838;
  --itav-brand: #22c55e;
  --itav-brand-strong: #15803d;
  --itav-brand-strong-hover: #166534;
  --itav-brand-soft: #e7f9ee;
  --itav-surface: #f6f8f7;
  --itav-border: #dce6e0;

  --cui-primary: #15803d;
  --cui-primary-rgb: 21, 128, 61;
  --cui-primary-text-emphasis: #14532d;
  --cui-primary-bg-subtle: #e7f9ee;
  --cui-primary-border-subtle: #b7e8c9;
  --cui-link-color: #15803d;
  --cui-link-color-rgb: 21, 128, 61;
  --cui-link-hover-color: #166534;
  --cui-link-hover-color-rgb: 22, 101, 52;
  --cui-tertiary-bg: #eef3f0;
  --cui-border-color: #dce6e0;
  --cui-focus-ring-color: rgba(34, 197, 94, .3);
  --cui-border-radius: .5rem;
}

[data-coreui-theme=dark] {
  --itav-ink: #12141c;
  --itav-ink-2: #1b1f2b;
  --itav-brand-strong: #22c55e;
  --itav-brand-strong-hover: #4ade80;
  --itav-brand-soft: rgba(34, 197, 94, .12);
  --itav-surface: #181b24;
  --itav-border: #2c3242;

  --cui-primary: #22c55e;
  --cui-primary-rgb: 34, 197, 94;
  --cui-primary-text-emphasis: #86efac;
  --cui-primary-bg-subtle: rgba(34, 197, 94, .12);
  --cui-primary-border-subtle: rgba(34, 197, 94, .35);
  --cui-link-color: #4ade80;
  --cui-link-color-rgb: 74, 222, 128;
  --cui-link-hover-color: #86efac;
  --cui-link-hover-color-rgb: 134, 239, 172;
  --cui-border-color: #2c3242;
  --cui-tertiary-bg: #2a303d;
}

body { background-color: var(--itav-surface); }

/* ---------------------------------------------------------------------
   Meniul lateral: antracit, element activ marcat cu verde
   --------------------------------------------------------------------- */
.sidebar.sidebar-dark {
  --cui-sidebar-bg: var(--itav-ink);
  --cui-sidebar-nav-link-active-bg: rgba(34, 197, 94, .14);
  --cui-sidebar-nav-link-active-color: #fff;
  --cui-sidebar-nav-link-active-icon-color: var(--itav-brand);
  --cui-sidebar-nav-link-hover-bg: rgba(255, 255, 255, .06);
}
.sidebar.sidebar-dark.sidebar-super {
  --cui-sidebar-bg: #0f1117;
}
.sidebar .sidebar-brand { color: #fff; text-decoration: none; gap: .5rem; }
.sidebar .sidebar-brand .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .5rem;
  background: var(--itav-brand); color: #0b1a10; font-weight: 800;
}
.sidebar .sidebar-brand .brand-version { font-size: .75rem; opacity: .55; font-weight: 400; }
.sidebar-nav .nav-link.active { box-shadow: inset 3px 0 0 var(--itav-brand); }
.sidebar-nav .nav-title { color: rgba(255, 255, 255, .45); }

/* ---------------------------------------------------------------------
   Antet si continut
   --------------------------------------------------------------------- */
.header .company-name { font-weight: 600; }
.header .company-cui { font-size: .8rem; color: var(--cui-secondary-color); }
.avatar-initial {
  width: 2rem; height: 2rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cui-primary); color: #fff; font-weight: 700;
}
[data-coreui-theme=dark] .avatar-initial { color: #0b1a10; }

h1, h2, h3, h4, h5, h6 { font-weight: 600; }
.page-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h4, .page-header h1 { margin: 0; }

/* ---------------------------------------------------------------------
   Butoane: verde ca actiune principala
   --------------------------------------------------------------------- */
.btn { font-weight: 500; }
.btn-primary,
[data-coreui-theme] .btn-primary {
  --cui-btn-bg: var(--itav-brand-strong);
  --cui-btn-border-color: var(--itav-brand-strong);
  --cui-btn-color: #fff;
  --cui-btn-hover-bg: var(--itav-brand-strong-hover);
  --cui-btn-hover-border-color: var(--itav-brand-strong-hover);
  --cui-btn-hover-color: #fff;
  --cui-btn-active-bg: var(--itav-brand-strong-hover);
  --cui-btn-active-border-color: var(--itav-brand-strong-hover);
  --cui-btn-active-color: #fff;
  --cui-btn-disabled-bg: var(--itav-brand-strong);
  --cui-btn-disabled-border-color: var(--itav-brand-strong);
  --cui-btn-focus-shadow-rgb: 34, 197, 94;
}
html[data-coreui-theme=dark] .btn-primary {
  --cui-btn-color: #0b1a10;
  --cui-btn-hover-color: #0b1a10;
  --cui-btn-active-color: #0b1a10;
}
.btn-outline-primary,
[data-coreui-theme] .btn-outline-primary {
  --cui-btn-color: var(--itav-brand-strong);
  --cui-btn-border-color: var(--itav-brand-strong);
  --cui-btn-hover-bg: var(--itav-brand-strong);
  --cui-btn-hover-border-color: var(--itav-brand-strong);
  --cui-btn-hover-color: #fff;
  --cui-btn-active-bg: var(--itav-brand-strong);
  --cui-btn-active-border-color: var(--itav-brand-strong);
  --cui-btn-active-color: #fff;
  --cui-btn-focus-shadow-rgb: 34, 197, 94;
}
html[data-coreui-theme=dark] .btn-outline-primary { --cui-btn-hover-color: #0b1a10; --cui-btn-active-color: #0b1a10; }

.form-control:focus,
.form-select:focus {
  border-color: var(--itav-brand);
  box-shadow: 0 0 0 .2rem rgba(34, 197, 94, .2);
}
.form-check-input:checked { background-color: var(--cui-primary); border-color: var(--cui-primary); }

/* ---------------------------------------------------------------------
   Carduri si tabele
   --------------------------------------------------------------------- */
.card { border-color: var(--itav-border); box-shadow: 0 1px 2px rgba(26, 29, 41, .05); }
.card-header { background-color: var(--itav-brand-soft); font-weight: 600; }
.table { --cui-table-bg: transparent; }
.table > thead th,
.table > thead td {
  background-color: var(--itav-brand-soft);
  font-weight: 600;
  white-space: nowrap;
  font-size: .85rem;
}
.card > .table-responsive > .table,
.card > .table { margin-bottom: 0; }
.card > .table-responsive > .table > :not(caption) > * > *:first-child,
.card > .table > :not(caption) > * > *:first-child { padding-left: 1rem; }
.card > .table-responsive > .table > :not(caption) > * > *:last-child,
.card > .table > :not(caption) > * > *:last-child { padding-right: 1rem; }
.table-hover > tbody > tr:hover > * { --cui-table-bg-state: var(--itav-brand-soft); }

/* ---------------------------------------------------------------------
   Bara de cautare a listelor + paginare
   --------------------------------------------------------------------- */
.list-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.list-toolbar .list-search { max-width: 22rem; flex: 1 1 14rem; }
.list-footer { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; border-top: 1px solid var(--cui-border-color); }
.list-footer .pagination { margin: 0; }
.pagination {
  --cui-pagination-active-bg: var(--cui-primary);
  --cui-pagination-active-border-color: var(--cui-primary);
  --cui-pagination-color: var(--cui-link-color);
  --cui-pagination-hover-color: var(--cui-link-hover-color);
  --cui-pagination-focus-color: var(--cui-link-hover-color);
  --cui-pagination-focus-box-shadow: 0 0 0 .2rem rgba(34, 197, 94, .25);
}
[data-coreui-theme=dark] .pagination { --cui-pagination-active-color: #0b1a10; }

/* ---------------------------------------------------------------------
   Ecranele de autentificare
   --------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 15% 12%, rgba(34, 197, 94, .14), transparent 42%),
    radial-gradient(circle at 85% 88%, rgba(34, 197, 94, .08), transparent 45%),
    var(--itav-ink);
}
.auth-shell .auth-top { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; color: #fff; }
.auth-shell .auth-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; }
.auth-shell .auth-brand .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .5rem; background: var(--itav-brand); color: #0b1a10; font-weight: 800;
}
.auth-shell main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-shell .auth-footer { color: rgba(255, 255, 255, .45); text-align: center; font-size: .8rem; padding: 1rem; }
.card-auth { width: 100%; max-width: 30rem; border-top: 3px solid var(--itav-brand); }
.card-auth.card-auth-wide { max-width: 36rem; }
.choose-list .list-group-item-action { color: var(--cui-body-color); }

/* Comutatorul de limba pe fundal inchis */
.lang-switch .btn { min-width: 2.4rem; }

/* Focus vizibil, mereu (accesibilitate) */
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--itav-brand);
  outline-offset: 2px;
}

/* Tiparire: fara meniu, antet, butoane */
@media print {
  .sidebar, .header, .no-print, .list-toolbar, .list-footer, footer.footer { display: none !important; }
  .wrapper { padding-left: 0 !important; }
  body { background: #fff !important; }
}

/* search (step 7) ------------------------------------------------------
   Cautarea globala din antet (views/layout/header_search.php, public/assets/js/search.js)
   si pagina de rezultate (views/search/index.php).
   --------------------------------------------------------------------- */
.header-search { position: relative; margin-inline: .5rem; }
.header-search-toggle { display: none; color: var(--cui-header-color); }
.header-search-form { position: relative; display: flex; align-items: center; width: 17rem; margin: 0; }
.header-search-icon {
  position: absolute; inset-inline-start: .65rem; top: 50%; transform: translateY(-50%);
  color: var(--cui-secondary-color); pointer-events: none;
}
.header-search-input.form-control {
  padding-inline-start: 2rem; padding-inline-end: 2rem;
  background-color: var(--cui-tertiary-bg); border-color: transparent;
}
.header-search-input.form-control:focus { background-color: var(--cui-body-bg); border-color: var(--cui-primary-border-subtle); }
.header-search-input::-webkit-search-cancel-button { display: none; }
.header-search-kbd {
  position: absolute; inset-inline-end: .5rem; top: 50%; transform: translateY(-50%);
  padding: .05rem .4rem; font-size: .7rem; line-height: 1.2; pointer-events: none;
  color: var(--cui-secondary-color); background: var(--cui-body-bg); border: 1px solid var(--cui-border-color); border-radius: .3rem;
}
.header-search-input:focus ~ .header-search-kbd,
.header-search-input:not(:placeholder-shown) ~ .header-search-kbd { display: none; }
.header-search-close { display: none; }
@media (min-width: 1200px) { .header-search-form { width: 22rem; } }

.header-search-dropdown {
  position: absolute; top: calc(100% + .35rem); inset-inline-end: 0; z-index: 1040;
  width: 28rem; max-width: calc(100vw - 2rem); max-height: min(70vh, 34rem); overflow-y: auto;
  padding: .25rem 0; background: var(--cui-body-bg); color: var(--cui-body-color);
  border: 1px solid var(--cui-border-color); border-radius: var(--cui-border-radius);
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .15);
}
[data-coreui-theme=dark] .header-search-dropdown { box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .5); }
.header-search-group {
  display: flex; align-items: center; padding: .5rem .85rem .2rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--cui-secondary-color);
}
.header-search-option {
  display: flex; align-items: flex-start; gap: .65rem; padding: .4rem .85rem;
  color: var(--cui-body-color); text-decoration: none; scroll-margin: .25rem;
}
.header-search-option:hover,
.header-search-option.active { background: var(--itav-brand-soft); color: var(--cui-body-color); }
.header-search-option.active { box-shadow: inset 3px 0 0 var(--itav-brand); }
.header-search-option-icon { flex: none; margin-top: .2rem; color: var(--cui-secondary-color); }
.header-search-option-body { display: flex; flex-direction: column; min-width: 0; }
.header-search-option-label { font-weight: 500; overflow-wrap: anywhere; }
.header-search-option-sub { font-size: .8rem; color: var(--cui-secondary-color); overflow-wrap: anywhere; }
.header-search-all {
  position: sticky; bottom: -.25rem; margin-top: .25rem; padding-top: .55rem; padding-bottom: .55rem;
  border-top: 1px solid var(--cui-border-color); background: var(--cui-body-bg); color: var(--cui-link-color); font-weight: 500;
}
.header-search-all.active { background: var(--cui-body-bg); background-image: linear-gradient(var(--itav-brand-soft), var(--itav-brand-soft)); }
.header-search-all .header-search-option-icon { color: inherit; }
.header-search-message { padding: .75rem .85rem; font-size: .875rem; color: var(--cui-secondary-color); }
.header-search-dropdown mark,
.search-results mark { padding: 0 .05em; border-radius: .15rem; background: rgba(250, 204, 21, .45); color: inherit; }
[data-coreui-theme=dark] .header-search-dropdown mark,
[data-coreui-theme=dark] .search-results mark { background: rgba(250, 204, 21, .3); }

/* Telefon / tableta ingusta: doar iconita; caseta se deschide peste tot antetul */
@media (max-width: 767.98px) {
  .header-search { position: static; margin-inline: 0; }
  .header-search-toggle { display: inline-flex; }
  .header-search-form {
    display: none; position: absolute; inset: 0; z-index: 1035; width: auto;
    padding: 0 .75rem; gap: .5rem; background: var(--cui-header-bg, var(--cui-body-bg));
  }
  .header-search.is-open .header-search-form { display: flex; }
  .header-search-icon { inset-inline-start: 1.4rem; }
  .header-search-input.form-control { flex: 1 1 auto; min-width: 0; padding-inline-end: .75rem; }
  .header-search-kbd { display: none; }
  .header-search-close { display: inline-flex; flex: none; color: var(--cui-secondary-color); }
  .header-search-dropdown { top: 100%; inset-inline: .5rem; width: auto; max-width: none; max-height: 75vh; }
}

.search-page-form { max-width: 40rem; }
.search-results .search-result { color: var(--cui-body-color); }
/* /search (step 7) */

/* notifications (step 7) ------------------------------------------------
   Clopotelul din antet, lista de notificari, preferinte, Super Admin -> Email */
.notif-bell > .nav-link { position: relative; }
.notif-bell .notif-badge {
  position: absolute; top: .1rem; right: -.1rem;
  font-size: .62rem; line-height: 1; padding: .22em .42em; min-width: 1.15rem;
}
.notif-menu { width: 23rem; max-width: calc(100vw - 1rem); overflow: hidden; }
.notif-menu-head, .notif-menu-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .6rem 1rem;
}
.notif-menu-head { border-bottom: 1px solid var(--cui-border-color); }
.notif-menu-foot { border-top: 1px solid var(--cui-border-color); }
.notif-list { max-height: min(26rem, 60vh); overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: .6rem;
  white-space: normal; padding: .6rem 1rem;
  border-bottom: 1px solid var(--cui-border-color-translucent);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item .notif-body { display: flex; flex-direction: column; min-width: 0; }
.notif-item .notif-text { font-size: .875rem; overflow-wrap: anywhere; }
.notif-item .notif-meta { font-size: .75rem; color: var(--cui-secondary-color); }
.notif-item.is-unread { background: rgba(34, 197, 94, .07); }
.notif-item.is-unread .notif-text { font-weight: 600; }
.notif-dot {
  flex: 0 0 auto; width: .5rem; height: .5rem; margin-top: .4rem; border-radius: 50%;
  background: transparent;
}
.is-unread > .notif-dot { background: var(--itav-brand, #22c55e); }
.notif-row.is-unread { background: rgba(34, 197, 94, .06); }
.notif-row-text { overflow-wrap: anywhere; }
.notif-prefs td:first-child { min-width: 14rem; }
.notif-prefs .form-check-input { width: 1.15em; height: 1.15em; }
.smtp-transcript {
  max-height: 16rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--cui-tertiary-bg); color: var(--cui-body-color);
  border: 1px solid var(--cui-border-color); border-radius: .375rem; padding: .6rem .75rem;
}
.queue-error { max-width: 22rem; overflow-wrap: anywhere; }
.queue-to { min-width: 11rem; }
.queue-subject { min-width: 14rem; overflow-wrap: anywhere; }
.queue-status { min-width: 8rem; max-width: 11rem; }
@media (max-width: 575.98px) {
  .notif-bell { position: static; }
  .notif-menu { width: calc(100vw - 1rem); }
}
/* end notifications (step 7) */

/* charts (step 8) -------------------------------------------------------
   Graficele rapoartelor (assets/js/charts.js citeste culorile de aici). */
:root,
[data-coreui-theme=light] {
  --chart-1: #16a34a;
  --chart-2: #64748b;
  --chart-ink: #1a1d29;
  --chart-grid: rgba(26, 29, 41, .08);
  --chart-text: #6b7280;
  --chart-surface: #ffffff;
  --chart-tooltip: #1a1d29;
  --chart-age-0: #16a34a;
  --chart-age-1: #ca8a04;
  --chart-age-2: #ea580c;
  --chart-age-3: #dc2626;
  --chart-age-4: #991b1b;
}
[data-coreui-theme=dark] {
  --chart-1: #22c55e;
  --chart-2: #94a3b8;
  --chart-ink: #e5e7eb;
  --chart-grid: rgba(255, 255, 255, .08);
  --chart-text: #9ca3af;
  --chart-surface: #212631;
  --chart-tooltip: #0b0d12;
  --chart-age-0: #22c55e;
  --chart-age-1: #facc15;
  --chart-age-2: #fb923c;
  --chart-age-3: #f87171;
  --chart-age-4: #dc2626;
}
.chart-box { position: relative; min-width: 0; }
.chart-canvas { position: relative; width: 100%; height: var(--chart-h, 280px); }
.chart-canvas canvas { display: block; max-width: 100%; }
.chart-box.is-empty .chart-canvas { display: none; }
.chart-empty {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 8rem; margin: 0; padding: 1rem; text-align: center;
  color: var(--cui-secondary-color); font-size: .9rem;
  border: 1px dashed var(--cui-border-color); border-radius: var(--cui-border-radius);
}
.chart-range { font-weight: 400; color: var(--cui-secondary-color); font-size: .8rem; }
.chart-data { margin-top: .75rem; }
.chart-data > summary { cursor: pointer; color: var(--cui-secondary-color); font-size: .8rem; width: max-content; }
.chart-data > summary:hover { color: var(--cui-body-color); }
.chart-data .table { font-size: .8rem; }
@media (max-width: 575.98px) {
  .chart-canvas { height: min(var(--chart-h, 280px), 230px); }
}
/* /charts (step 8) */
