/* ============================================================
   assets/css/app.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --blue-dark:  #1d4ed8;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --red:        #dc2626;
  --green:      #16a34a;
  --orange:     #d97706;
  --sidebar-w:  240px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.nav-links {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-link.active { background: var(--blue-light); color: var(--blue); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }

.logout-btn { color: var(--gray-400); text-decoration: none; flex-shrink: 0; }
.logout-btn svg { width: 18px; height: 18px; display: block; }
.logout-btn:hover { color: var(--red); }

/* ---- Main ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
}
.main-inner { max-width: 1100px; margin: 0 auto; }

/* ---- Flash ---- */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 500;
}
.flash--success { background: #dcfce7; color: #166534; }
.flash--error   { background: #fee2e2; color: #991b1b; }
.flash--info    { background: var(--blue-light); color: #1e40af; }

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.page-subtitle { font-size: 13px; color: var(--gray-400); margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: none; cursor: pointer;
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: #fff; color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer; color: var(--gray-400); }
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-icon svg { display: block; }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
}
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--gray-400); pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }

.filter-select {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }

/* ---- Table ---- */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.contact-name { font-weight: 600; color: var(--gray-800); }
.contact-sub  { font-size: 12px; color: var(--gray-400); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-light); color: var(--blue); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }

/* ---- Cards ---- */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}
textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

/* ---- Multifield (Telefon / Email) ---- */
.multifield { display: flex; flex-direction: column; gap: 6px; }
.multifield-row { display: flex; gap: 6px; align-items: center; }
.multifield-row select { width: 110px; flex-shrink: 0; }
.multifield-row .input { flex: 1; }

/* ---- Pagination ---- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px; color: var(--gray-600);
}
.pagination-links { display: flex; gap: 4px; }
.page-link {
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid var(--gray-200);
  background: #fff;
  font-size: 12px; cursor: pointer; text-decoration: none; color: var(--gray-800);
}
.page-link.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-link:hover:not(.active) { background: var(--gray-100); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: 600px; max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; }

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-50);
}
.login-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 36px 32px;
  width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
  font-size: 18px; font-weight: 700;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .subtitle { color: var(--gray-400); font-size: 13px; margin-bottom: 24px; }

/* ---- Card section title ---- */
.card-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: 14px;
}

/* ---- Toggle labels (Flags) ---- */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.toggle-label input { display: none; }
.toggle-label:hover { background: var(--gray-50); }
.toggle-label--on { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ---- Avatar stack ---- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

/* ---- Group color dot ---- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
