/*
 * ModularApp — Base Stylesheet
 * Structural styles independent of theme colour.
 * Theme-specific colours are in theme-light.css and theme-dark.css.
 */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  min-height: 100%;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-wrapper { width: 100%; max-width: 420px; }

.auth-card {
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.app-icon { font-size: 2rem; }
.auth-app-name { font-size: 1.35rem; font-weight: 700; }
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 20px; }
.auth-subtitle { font-size: 0.9rem; margin-bottom: 20px; opacity: .75; }
.auth-links { margin-top: 16px; text-align: center; font-size: 0.875rem; }

/* --- App layout --- */
.app-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease;
  overflow-x: hidden;
}

.sidebar.collapsed { width: 56px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  font-weight: 700;
  font-size: 1.05rem;
}

.sidebar-brand { flex: 1; white-space: nowrap; overflow: hidden; }

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 4px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.nav-link, .nav-child-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 6px;
  margin: 2px 8px;
  transition: background .15s;
  white-space: nowrap;
}
.nav-link:hover, .nav-child-link:hover { text-decoration: none; }

.nav-icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-child-link { padding-left: 32px; font-size: 0.87rem; }

/* Nav children: hidden by default, visible only when parent has .open */
.nav-children {
  display: none;
}
.nav-item.has-children.open > .nav-children {
  display: block;
  animation: navChildIn .18s ease;
}
@keyframes navChildIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Collapsed sidebar: center icons, show tooltip on hover */
.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-child-link {
  justify-content: center;
  padding: 9px 0;
  margin: 2px 6px;
}
.sidebar.collapsed .nav-icon {
  width: auto;
  font-size: 1.25rem;
}
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-children { display: none; }

.nav-arrow { margin-left: auto; font-size: 0.75rem; transition: transform .2s; }
.nav-item.open > .nav-link .nav-arrow { transform: rotate(90deg); }

/* ===== Main area ===== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.1);
  gap: 12px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-menu-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}

.topbar-title { font-weight: 600; font-size: 1rem; }

/* ===== Topbar breadcrumb ===== */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: .875rem;
  min-width: 0;
}
.topbar-breadcrumb .bc-link {
  color: var(--accent, #4f46e5);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  opacity: .85;
  transition: opacity .15s;
}
.topbar-breadcrumb .bc-link:hover { opacity: 1; text-decoration: underline; }
.topbar-breadcrumb .bc-text {
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
}
.topbar-breadcrumb .bc-sep {
  color: var(--text-secondary, #6b7280);
  opacity: .5;
  font-size: .8rem;
  flex-shrink: 0;
}
.topbar-breadcrumb .bc-current {
  font-weight: 600;
  color: var(--text-primary, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* ===== Page content ===== */
.page-content { flex: 1; padding: 24px; overflow-y: auto; }
.page-title   { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.page-subtitle{ font-size: 0.9rem; opacity: .7; margin-bottom: 24px; }

/* ===== Dashboard ===== */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 12px;
}

.module-card {
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
}
.module-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.13); text-decoration: none; }

.module-card-icon { font-size: 2rem; }
.module-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.module-card-children { font-size: 0.82rem; opacity: .7; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 6px; }
.required { color: #e53e3e; }

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9375rem;
  border-radius: 6px;
  border: 1.5px solid transparent;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.18); }

.input-group { display: flex; }
.input-group .form-control { border-radius: 6px 0 0 6px; flex: 1; }
.input-addon { border-radius: 0 6px 6px 0; padding: 0 12px; border: 1.5px solid transparent; border-left: none; cursor: pointer; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1 1 180px; }
.form-section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: 20px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border-color); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 6px; border-radius: 4px; font-size: 1rem; }

.btn-primary   { background: #4f46e5; color: #fff; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid currentColor; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-close   { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 0.9rem; opacity: .6; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-write { background: #dcfce7; color: #166534; }
.badge-read  { background: #dbeafe; color: #1e40af; }
.badge-view  { background: #fef9c3; color: #854d0e; }
.badge-none  { background: #f3f4f6; color: #6b7280; }

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  margin-top: 16px;
  /* Thin, unobtrusive scrollbar — only visible when content actually overflows */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.18) transparent;
}
.table-wrapper::-webkit-scrollbar { height: 4px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }
.table-wrapper::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { padding: 12px 14px; text-align: left; font-weight: 600; white-space: nowrap; }
tbody td { padding: 10px 14px; vertical-align: middle; }

.table-actions { display: flex; gap: 6px; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 5px; font-size: 0.875rem; min-width: 36px; text-align: center; text-decoration: none;
}

/* ===== Filters bar ===== */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filters-bar .form-group { margin-bottom: 0; }
.filters-bar .form-control { padding: 7px 10px; font-size: 0.875rem; }

/* ===== User menu ===== */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.dropdown-arrow { font-size: 0.7rem; opacity: .6; }

.user-dropdown {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  min-width: 170px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  z-index: 200;
  display: none;
}
.user-dropdown.open { display: block; }
.dropdown-item { display: block; padding: 9px 16px; font-size: 0.9rem; text-decoration: none; }
.dropdown-item:hover { text-decoration: none; }
.dropdown-divider { border: none; border-top: 1px solid; margin: 4px 0; }
.text-danger { color: #dc2626; }

/* ===== Language selector ===== */
.lang-form { display: flex; align-items: center; }
.lang-select { padding: 5px 8px; border-radius: 5px; font-size: 0.85rem; border: 1px solid; cursor: pointer; }

/* ===== Theme toggle ===== */
.theme-toggle { font-size: 1.1rem; }

/* ===== Error page ===== */
.error-page { text-align: center; padding: 60px 20px; }
.error-code  { font-size: 80px; font-weight: 800; opacity: .2; }
.error-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
.error-message { margin-bottom: 28px; opacity: .7; }

/* ===== Module page header ===== */
.module-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== Card ===== */
.card { border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); margin-bottom: 20px; }
.card-body { padding: 20px 24px; }

/* ===== Select ===== */
select.form-control { appearance: auto; cursor: pointer; }

/* ===== Helpers ===== */
.text-muted   { opacity: .6; font-size: 0.875rem; }
.text-center  { text-align: center; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-2  { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -240px; top: 0; height: 100%; z-index: 300; transition: left .25s; }
  .sidebar.open { left: 0; }
  .main-wrapper { margin-left: 0; }
  .form-row { flex-direction: column; }
  .module-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .module-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}

/* ===== Icon buttons ===== */
.btn-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  background: none;
  padding: 0;
  transition: background .15s, transform .1s;
  position: relative;
  text-decoration: none;
}
.btn-icon-action:hover { text-decoration: none; transform: scale(1.12); }
.btn-icon-action:active { transform: scale(.94); }

.btn-icon-edit    { color: #4f46e5; }
.btn-icon-toggle-off { color: #d97706; }
.btn-icon-toggle-on  { color: #16a34a; }
.btn-icon-delete  { color: #dc2626; }
.btn-icon-filter  { color: #4f46e5; }
.btn-icon-reset   { color: #6b7280; }

.btn-icon-edit:hover    { background: rgba(79,70,229,.12); }
.btn-icon-toggle-off:hover { background: rgba(217,119,6,.12); }
.btn-icon-toggle-on:hover  { background: rgba(22,163,74,.12); }
.btn-icon-delete:hover  { background: rgba(220,38,38,.12); }
.btn-icon-filter:hover  { background: rgba(79,70,229,.12); }
.btn-icon-reset:hover   { background: rgba(107,114,128,.12); }

/* ===== Invoice state badges ===== */
.badge-state-draft    { background: #f3f4f6; color: #6b7280; }
.badge-state-emisa    { background: #dbeafe; color: #1e40af; }
.badge-state-anulata  { background: #fee2e2; color: #991b1b; }
.badge-state-stornata { background: #fef3c7; color: #92400e; }

/* ===== Invoice summary cards (sub header) ===== */
.inv-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.inv-summary-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  gap: 2px;
}
.inv-summary-card .isc-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary, #111827);
}
.inv-summary-card .isc-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary, #6b7280);
  font-weight: 600;
}

/* ===== Tooltip ===== */
[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,.88);
  color: #fff;
  font-size: 0.75rem;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 999;
}
[data-tip]:hover::after { opacity: 1; }

/* ===== Status badges with icons ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-active   { background: #dcfce7; color: #166534; }
.status-inactive { background: #f3f4f6; color: #6b7280; }
.status-pending  { background: #fef3c7; color: #92400e; }
.status-error    { background: #fee2e2; color: #991b1b; }

/* ===== Record ID badge (form view mode) ===== */
.record-id-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99,102,241,.12);
  color: #4f46e5;
  letter-spacing: .03em;
  vertical-align: middle;
  margin-left: 8px;
}

/* ===== Sub-modules trigger button ===== */
.btn-submodules-trigger {
  color: #0891b2;
  width: 28px;
  height: 28px;
  font-size: .95rem;
}
.btn-submodules-trigger:hover { background: rgba(8,145,178,.12); color: #0e7490; }

/* ===== Sub-modules dropdown menu ===== */
.submods-menu {
  position: absolute;
  z-index: 1050;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.13);
  min-width: 190px;
  padding: 5px 0;
  animation: submodsMenuIn .14s ease;
}
@keyframes submodsMenuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.submods-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  color: var(--text-primary, #111827);
  text-decoration: none;
  font-size: .875rem;
  transition: background .13s, color .13s;
  white-space: nowrap;
}
.submods-menu-item:hover {
  background: var(--bg-table-hover, #f3f4f6);
  color: var(--accent, #4f46e5);
  text-decoration: none;
}
.submods-menu-item i {
  font-size: 1rem;
  opacity: .7;
  flex-shrink: 0;
}

/* ===== Legacy: keep sub-module page context header ===== */
/* (kept from modal era — .smf-value truncated, replaced below) */
/* ===== Sub-module master header (context bar) ===== */
.submodule-master-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-radius: 10px;
  margin-bottom: 18px;
  background: var(--bg-card, #fff);
  border-left: 4px solid var(--accent, #4f46e5);
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  flex-wrap: wrap;
}

.smh-identity {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.smh-icon {
  font-size: 1.6rem;
  color: var(--accent, #4f46e5);
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

.smh-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin-bottom: 4px;
}

.smh-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary, #6b7280);
}

.smh-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.smh-meta a {
  color: var(--accent, #4f46e5);
}

