/* Registru Online – stiluri aplicatie */
:root {
  --app-primary: #2f5bea;
  --app-primary-rgb: 47, 91, 234;
  --app-bg: #f4f6fb;
  --app-surface: #ffffff;
  --app-border: #e3e8f2;
  --app-topbar-h: 58px;
  --app-sidebar-w: 248px;
  --bs-primary: #2f5bea;
  --bs-primary-rgb: 47, 91, 234;
  --bs-link-color: #2f5bea;
  --bs-link-hover-color: #1f45c4;
  --bs-body-font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --app-primary: #7b9bff;
  --app-primary-rgb: 123, 155, 255;
  --app-bg: #0e1220;
  --app-surface: #161b2e;
  --app-border: #262d45;
  --bs-primary: #7b9bff;
  --bs-primary-rgb: 123, 155, 255;
  --bs-body-bg: #0e1220;
  --bs-body-bg-rgb: 14, 18, 32;
  --bs-link-color: #8fabff;
  --bs-link-hover-color: #b4c6ff;
  --bs-border-color: #262d45;
  --bs-tertiary-bg: #1c2238;
}
[data-bs-theme="dark"] .brand-logo { background: #fff; border-radius: .45rem; padding: .3rem .55rem; box-sizing: content-box; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #4a6fe8; --bs-btn-border-color: #4a6fe8; --bs-btn-hover-bg: #3a5cd0; --bs-btn-hover-border-color: #3a5cd0; --bs-btn-color: #fff; }

body { background: var(--app-bg); font-size: .9rem; -webkit-font-smoothing: antialiased; }
.tiny { font-size: .75rem; }
.btn-primary { --bs-btn-bg: #2f5bea; --bs-btn-border-color: #2f5bea; --bs-btn-hover-bg: #2548c4; --bs-btn-hover-border-color: #2548c4; --bs-btn-active-bg: #1f3ea8; --bs-btn-active-border-color: #1f3ea8; }
.btn-outline-primary { --bs-btn-color: #2f5bea; --bs-btn-border-color: #2f5bea; --bs-btn-hover-bg: #2f5bea; --bs-btn-hover-border-color: #2f5bea; }
.nav-pills { --bs-nav-pills-link-active-bg: rgba(var(--app-primary-rgb), .12); --bs-nav-pills-link-active-color: var(--app-primary); }

/* Topbar */
.topbar { height: var(--app-topbar-h); background: var(--app-surface); border-bottom: 1px solid var(--app-border); padding: 0; z-index: 1030; }
.topbar .navbar-brand { color: var(--bs-body-color); }
.global-search { max-width: 640px; }
.global-search .input-group-text, .global-search .form-control { background: var(--bs-tertiary-bg); border-color: transparent; }
.global-search .form-control:focus { box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .18); border-color: rgba(var(--app-primary-rgb), .5); background: var(--app-surface); }
.btn-icon { --bs-btn-padding-x: .45rem; --bs-btn-padding-y: .25rem; border: 0; background: transparent; color: var(--bs-secondary-color); border-radius: .5rem; }
.btn-icon:hover, .btn-icon:focus-visible { background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.topbar .btn-icon { font-size: 1.15rem; }
.btn-user { border: 0; background: transparent; color: var(--bs-body-color); padding: .2rem .4rem; border-radius: .6rem; }
.btn-user:hover { background: var(--bs-tertiary-bg); }
.btn-user::after { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--app-primary-rgb), .14); color: var(--app-primary); font-weight: 700; }

/* Shell */
.shell { display: flex; min-height: calc(100vh - var(--app-topbar-h)); }
.sidebar { width: var(--app-sidebar-w); flex: 0 0 var(--app-sidebar-w); background: var(--app-surface); border-right: 1px solid var(--app-border); }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: var(--app-topbar-h); height: calc(100vh - var(--app-topbar-h)); }
  .sidebar .offcanvas-body { display: flex; padding: 1rem .75rem; overflow-y: auto; }
}
@media (max-width: 991.98px) { .sidebar { width: 280px; } .shell { display: block; } }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--bs-secondary-color); font-weight: 500; padding: .55rem .8rem; border-radius: .6rem; }
.sidebar .nav-link i { font-size: 1.1rem; }
.sidebar .nav-link:hover { background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.sidebar .nav-link.active { color: var(--app-primary); }
.storage { background: var(--bs-tertiary-bg); border: 0; }
.content { flex: 1 1 auto; min-width: 0; padding: 1.5rem; }
@media (max-width: 575.98px) { .content { padding: 1rem .75rem; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* Carduri */
.card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .9rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.stat { flex-direction: row; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat-icon { width: 44px; height: 44px; border-radius: .8rem; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; background: rgba(var(--app-primary-rgb), .12); color: var(--app-primary); flex: none; }
.stat-icon.in { background: rgba(25, 135, 84, .13); color: #198754; }
.stat-icon.out { background: rgba(13, 110, 253, .12); color: #0d6efd; }
.stat-val { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-lbl { color: var(--bs-secondary-color); font-size: .8rem; }

/* Tabele */
.table { --bs-table-bg: transparent; font-size: .875rem; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--app-primary-rgb), .05); }
.cell-clip { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.row-deleted > * { opacity: .55; text-decoration: line-through; }
.row-deleted .btn { text-decoration: none; }
.file-cell .ext-badge { font-size: .62rem; font-weight: 600; letter-spacing: .03em; }
.log-detail { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; word-break: break-word; }
div.dt-container { --bs-gutter-x: 0; }
div.dt-container .dt-search input { border-radius: .5rem; }
div.dt-container .dt-length select { border-radius: .5rem; }
div.dt-container .row:last-child, div.dt-container .dt-layout-row:last-child { padding: .5rem .75rem 0; }
div.dt-processing { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .6rem; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: .5rem 1rem; }
table.dataTable > tbody > tr > td { vertical-align: middle; }

/* Modale / viewer */
.modal-content { border: 1px solid var(--app-border); border-radius: 1rem; }
.viewer-body { height: 75vh; background: var(--bs-tertiary-bg); }
.viewer-frame { width: 100%; height: 100%; border: 0; background: #fff; }

/* Autentificare */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(var(--app-primary-rgb), .16), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(var(--app-primary-rgb), .12), transparent 60%), var(--app-bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 1.1rem; padding: 2rem 1.75rem; box-shadow: 0 10px 40px rgba(16, 24, 40, .10); }

.toast-container { z-index: 2000; }
:focus-visible { outline: 2px solid rgba(var(--app-primary-rgb), .6); outline-offset: 2px; }
@media print { .topbar, .sidebar, .page-head .btn, .toast-container { display: none !important; } }

/* ===== Mobil ===== */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 767.98px) {
  body { font-size: .95rem; }
  .form-control, .form-select { font-size: 16px; } /* evita zoom automat pe iOS */
  .topbar .container-fluid { padding-left: .5rem; padding-right: .5rem; gap: .25rem !important; }
  .global-search .form-control { padding-left: .25rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > div:last-child { width: 100%; }
  .page-head .btn { flex: 1 1 auto; }
  .stat { padding: .75rem; gap: .6rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; }
  .stat-val { font-size: 1.2rem; }
  .card-body { padding: .85rem; }
  .auth-card { padding: 1.5rem 1.25rem; }

  /* tabele -> carduri */
  .table-responsive { overflow: visible; }
  table#tbl, table#tbl tbody, table#tbl tr, table#tbl td { display: block; width: 100% !important; }
  table#tbl thead { display: none; }
  table#tbl tbody tr { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .8rem; margin-bottom: .75rem; padding: .35rem .85rem; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
  table#tbl tbody td { display: flex !important; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; padding: .4rem 0; border: 0; border-bottom: 1px dashed var(--app-border); background: transparent; box-shadow: none; }
  table#tbl tbody td:last-child { border-bottom: 0; padding-top: .6rem; }
  table#tbl tbody td::before { content: attr(data-label); flex: none; color: var(--bs-secondary-color); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; text-align: left; }
  table#tbl tbody td:first-child { display: none !important; } /* ID */
  table#tbl tbody td:last-child::before { display: none; }
  table#tbl tbody td:last-child > div { width: 100%; justify-content: flex-end; }
  table#tbl tbody td .cell-clip { max-width: 60vw; white-space: normal; }
  table#tbl tbody tr.dt-empty td, table#tbl tbody td.dt-empty { display: block !important; text-align: center; }
  table#tbl tbody td.dt-empty::before { display: none; }
  .row-deleted { opacity: .6; }
  .btn-icon { padding: .45rem .6rem; font-size: 1.1rem; }
  .file-cell .btn { padding: .4rem .55rem; }

  /* controale DataTables */
  div.dt-container .dt-layout-row { flex-direction: column; align-items: stretch; gap: .5rem; }
  div.dt-container .dt-layout-cell { width: 100%; justify-content: center !important; text-align: center; }
  div.dt-container .dt-paging .pagination { justify-content: center; flex-wrap: wrap; }
  div.dt-container .dt-search { width: 100%; }
  div.dt-container .dt-search input { width: 100%; margin: 0; }
  .viewer-body { height: 70vh; }
  .toast-container { left: 0; right: 0; }
}
@media (max-width: 575.98px) {
  .content { padding: .75rem .6rem; }
  .modal-footer .btn { flex: 1 1 auto; }
}

@media (max-width: 767.98px) {
  .page-head { margin-bottom: .75rem; gap: .5rem; }
  .page-head > div:first-child p { display: none; }
  .page-head > div:last-child { display: flex; flex-wrap: nowrap; gap: .4rem !important; }
  .page-head .btn { padding: .3rem .55rem; font-size: .82rem; white-space: nowrap; }
  .toggle-row .btn { font-size: .82rem; }
  #statsWrap .stat { padding: .5rem .65rem; }
  div.dt-container .dt-length { display: none; }
}
