/* ============================================================================
   cnbadmin portal contracte - stiluri principale
   Design system minimal cu variabile CSS
   ============================================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============================================================================
   LOGIN SCREEN
   ============================================================================ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}
.login-card {
  background: white;
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px;
}
.login-logo {
  font-size: 32px; font-weight: 700; text-align: center;
  color: var(--primary); margin-bottom: 4px;
}
.login-subtitle {
  text-align: center; color: var(--gray-500);
  font-size: 13px; margin-bottom: 28px;
}
.login-error {
  margin-top: 12px; padding: 10px 12px;
  background: var(--danger-light); color: var(--danger);
  border-radius: var(--radius); font-size: 13px;
  text-align: center; display: none;
}
.login-error.show { display: block; }

/* ============================================================================
   APP SHELL - Sidebar + Main Content
   ============================================================================ */
.app-shell {
  display: flex; min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-800);
}
.sidebar-logo {
  font-size: 20px; font-weight: 700; letter-spacing: -0.5px;
}
.sidebar-subtitle {
  font-size: 11px; color: var(--gray-400); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--gray-300); text-decoration: none;
  font-size: 14px; margin-bottom: 2px;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--gray-800); color: white; }
.nav-item.active {
  background: var(--primary); color: white;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--gray-800);
}
.user-info { margin-bottom: 8px; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }

.main-content {
  flex: 1; min-width: 0;
  padding: 24px 28px 60px;
}
.view-container { max-width: 1400px; margin: 0 auto; }

/* ============================================================================
   PAGE HEADER
   ============================================================================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 24px; padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}
.page-title {
  font-size: 24px; font-weight: 700; margin: 0;
  color: var(--gray-900);
}
.page-subtitle {
  color: var(--gray-500); font-size: 14px; margin-top: 2px;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.1s;
  text-decoration: none; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #d97706; }
.btn-secondary {
  background: white; color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50); border-color: var(--gray-400);
}
.btn-link {
  background: none; color: var(--gray-300);
  padding: 4px 8px; border: none; font-size: 12px;
}
.btn-link:hover { color: white; text-decoration: underline; }
.btn-large { padding: 11px 18px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 5px 8px; font-size: 13px; }

/* ============================================================================
   FORMS
   ============================================================================ */
label {
  display: block; margin-bottom: 14px;
}
label > span {
  display: block; margin-bottom: 4px;
  font-size: 13px; font-weight: 500; color: var(--gray-700);
}
label.required > span::after {
  content: ' *'; color: var(--danger);
}
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="date"], input[type="tel"],
textarea, select {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; color: var(--gray-900);
  background: white; transition: border 0.1s, box-shadow 0.1s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 60px; }
input[type="file"] { padding: 4px; }
.form-row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.form-help {
  font-size: 12px; color: var(--gray-500); margin-top: 4px;
}
.form-section {
  border-top: 1px solid var(--gray-200);
  padding-top: 18px; margin-top: 18px;
}
.form-section-title {
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 20px; margin-bottom: 16px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: -20px -20px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-title {
  font-size: 15px; font-weight: 600; margin: 0; color: var(--gray-800);
}

/* ============================================================================
   TABLES
   ============================================================================ */
.table-wrap {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  text-align: left; padding: 12px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--gray-600); text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--gray-50); }
table.data td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td {
  font-weight: 600; background: var(--gray-50);
  border-top: 2px solid var(--gray-300);
}

/* ============================================================================
   BADGES & STATUS
   ============================================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: #047857; }
.badge-amber { background: var(--warning-light); color: #92400e; }
.badge-red { background: var(--danger-light); color: #b91c1c; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #6d28d9; }

.firma-pill {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--primary-light); color: var(--primary-dark);
}

/* ============================================================================
   STATS GRID (Dashboard)
   ============================================================================ */
.stats-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: var(--radius-lg);
  padding: 18px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px; color: var(--gray-500);
  font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.3px; margin-bottom: 6px;
}
.stat-value {
  font-size: 28px; font-weight: 700; color: var(--gray-900);
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 12px; color: var(--gray-500); margin-top: 4px;
}

/* ============================================================================
   FILTERS BAR
   ============================================================================ */
.filters-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px; background: white;
  border-radius: var(--radius-lg); border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.filters-bar input, .filters-bar select { width: auto; min-width: 140px; }
.filters-bar .filter-label {
  font-size: 12px; font-weight: 600; color: var(--gray-600);
}

/* ============================================================================
   MODAL
   ============================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal-content {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.modal-content.modal-wide { max-width: 900px; }
.modal-content.modal-narrow { max-width: 440px; }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 600; margin: 0; color: var(--gray-900); }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--gray-400); line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */
.toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
  max-width: 400px;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--gray-900); color: white;
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: slideInRight 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================================
   EMPTY STATES, LOADING
   ============================================================================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-500);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }

.loading {
  display: flex; justify-content: center; align-items: center;
  padding: 60px; color: var(--gray-400);
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   TABS
   ============================================================================ */
.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}
.tab {
  padding: 9px 14px; border: none; background: none;
  color: var(--gray-600); font-size: 13px; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--gray-900); }
.tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
}

/* ============================================================================
   UTILS
   ============================================================================ */
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-bold { font-weight: 600; }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-small { font-size: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -240px; z-index: 100;
    transition: left 0.2s;
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  table.data { font-size: 12px; }
  table.data td, table.data th { padding: 8px 10px; }
}
