/* ================================================================
   EmAdmin — Dark Theme (EmDocs Design Language)
   ================================================================ */

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

body {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9rem;
  background: #0f172a;
  color: #f8fafc;
  line-height: 1.5;
  overflow: hidden;
}

a { color: #fbbf24; text-decoration: none; }
a:hover { color: #f59e0b; }

h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: #fbbf24; text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Top Bar ──────────────────────────────────────────── */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: #1A2F3F;
  border-bottom: 2px solid #FCD55B; height: 52px;
}
.top-bar-brand {
  font-size: 18px; color: #fff; letter-spacing: 0.5px; font-weight: 400;
}
.top-bar-brand strong { font-weight: 900; font-style: italic; letter-spacing: -0.5px; }
.top-bar-brand em { font-weight: 300; font-style: italic; }
.top-bar-appname {
  color: #FCD55B;
  font-size: 14px;
  letter-spacing: 2.1px;
  text-transform: uppercase;
  margin-left: 6px;
  font-style: normal;
  font-weight: 400;
}

/* User Menu */
.user-menu { position: relative; }
.user-menu-trigger {
  background: transparent; color: rgba(255,255,255,0.7);
  border: none; padding: 6px 0; cursor: pointer;
  font-size: 0.85rem; display: flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.user-menu-trigger:hover { color: #fff; }
.user-menu-caret { font-size: 0.65rem; opacity: 0.5; }
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: #1e293b; border: 1px solid #475569; border-radius: 8px;
  padding: 16px 20px; min-width: 240px; z-index: 10000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.user-menu-name { font-weight: 600; color: #f8fafc; font-size: 0.95rem; }
.user-menu-email { color: #64748b; font-size: 0.8rem; margin-top: 2px; }
.user-menu-role { color: #94a3b8; font-size: 0.85rem; margin-top: 4px; }
.user-menu-divider { height: 1px; background: #334155; margin: 12px 0; }
.user-menu-logout {
  background: none; border: none; color: #f87171; cursor: pointer;
  padding: 4px 0; font-size: 0.85rem; font-weight: 500; font-family: inherit;
}
.user-menu-logout:hover { text-decoration: underline; }
.user-menu-profile {
  display: block; color: #cbd5e1; font-size: 0.85rem;
  padding: 4px 0; text-decoration: none; transition: color 0.15s;
}
.user-menu-profile:hover { color: #fbbf24; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: 280px; background: #1e293b;
  position: fixed; top: 52px; left: 0;
  height: calc(100vh - 52px); overflow-y: auto;
  border-right: 1px solid #334155; z-index: 1000;
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid #334155; background: #1a365d;
}
.sidebar-header h2 { font-size: 15px; font-weight: 600; color: #f8fafc; margin-bottom: 2px; }
.sidebar-role { font-size: 12px; color: #94a3b8; }

/* Sidebar Users Link */
.sidebar-users-link {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; color: #94a3b8; text-decoration: none;
  font-size: 0.9rem; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.sidebar-users-link:hover { background: rgba(51,65,85,0.4); color: #cbd5e1; }
.sidebar-users-link.active { color: #fbbf24; background: rgba(251,191,36,0.08); }
.sidebar-users-icon { font-size: 16px; }
.sidebar-divider { height: 1px; background: #334155; margin: 0; }

/* Sidebar Search */
.sidebar-search { padding: 8px 12px; }
.sidebar-search-input {
  width: 100%; padding: 6px 10px; font-size: 0.8rem;
  background: rgba(15,23,42,0.5); border: 1px solid #334155;
  border-radius: 6px; color: #f8fafc;
}
.sidebar-search-input:focus { border-color: #fbbf24; outline: none; }
.sidebar-search-input::placeholder { color: #64748b; }

/* App Accordion */
.app-accordion { display: flex; flex-direction: column; }
.app-section { border-bottom: 1px solid #334155; }
.app-section.expanded .app-tenants { display: block; }
.app-section.expanded .app-chevron { transform: rotate(90deg); }
.app-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; font-size: 0.85rem; font-weight: 600;
  color: #94a3b8; cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s;
}
.app-header:hover { background: rgba(51,65,85,0.4); color: #cbd5e1; }
.app-icon { flex-shrink: 0; font-size: 14px; }
.app-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-count {
  font-size: 0.7rem; font-weight: 500; color: #64748b;
  background: rgba(51,65,85,0.5); padding: 1px 6px; border-radius: 8px;
}
.app-chevron { font-size: 10px; transition: transform 0.2s; }
.app-tenants { display: none; padding: 4px 8px 8px; }
.tenant-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 6px; margin: 2px 0;
  background: rgba(51,65,85,0.3); color: #f8fafc; text-decoration: none;
  transition: background 0.15s; font-size: 0.85rem;
}
.tenant-item:hover { background: rgba(51,65,85,0.6); }
.tenant-item.active { background: #fbbf24; color: #1a365d; font-weight: 500; }
.tenant-stats { display: flex; gap: 6px; font-size: 0.7rem; color: #94a3b8; }
.tenant-item.active .tenant-stats { color: #1a365d; }
.stat { background: rgba(51,65,85,0.5); padding: 1px 6px; border-radius: 8px; }
.tenant-item.active .stat { background: rgba(26,54,93,0.2); }

/* ── Main Area ──────────────────────────────────────────── */
.main-area {
  position: absolute; top: 52px; left: 280px;
  width: calc(100vw - 280px); height: calc(100vh - 52px);
  background: #0f172a; overflow-y: auto;
}
.main-area-full { left: 0; width: 100vw; }
.main-content { padding: 32px; }

/* ── Tenant Header ──────────────────────────────────────── */
.tenant-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #334155;
}
.tenant-meta { display: flex; gap: 12px; }
.meta-badge {
  font-size: 0.8rem; color: #94a3b8;
  background: rgba(51,65,85,0.5); padding: 4px 12px; border-radius: 8px;
  border: 1px solid #475569;
}

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: rgba(30,41,59,0.5); padding: 4px;
  border-radius: 8px; border: 1px solid #334155;
}
.tab {
  background: transparent; color: #94a3b8;
  border: 1px solid transparent; padding: 8px 20px;
  border-radius: 6px; cursor: pointer; font-size: 0.85rem;
  font-weight: 500; transition: all 0.2s; font-family: inherit;
}
.tab:hover { background: rgba(251,191,36,0.1); color: #fbbf24; }
.tab.active { background: #fbbf24; color: #1a365d; border-color: #fbbf24; font-weight: 600; }

/* ── Tab Panel ──────────────────────────────────────────── */
.tab-panel { animation: fadeIn 0.15s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; gap: 16px; flex-wrap: wrap;
}
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Data Table ──────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  background: rgba(30,41,59,0.4); border-radius: 8px; overflow: hidden;
  border: 1px solid #334155;
}
.data-table thead { background: #334155; }
.data-table th {
  padding: 12px 16px; font-size: 0.8rem; font-weight: 600;
  color: #94a3b8; text-align: left; text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table td {
  padding: 12px 16px; font-size: 0.85rem; color: #f8fafc;
  border-bottom: 1px solid rgba(51,65,85,0.5);
}
.data-table tr:hover { background: rgba(51,65,85,0.3); }
.text-secondary { color: #94a3b8; }

/* ── Department List (Gruppen Tab) ────────────────────── */
.dept-list { display: flex; flex-direction: column; gap: 4px; }
.dept-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(30,41,59,0.6);
  border: 1px solid rgba(71,85,105,0.3); border-radius: 8px;
  transition: background 0.15s;
}
.dept-row:hover { background: rgba(30,41,59,0.9); }
.dept-info { display: flex; align-items: center; gap: 12px; }
.dept-name { font-size: 0.95rem; font-weight: 500; }
.dept-icon { color: #fbbf24; }
.dept-members { font-size: 0.75rem; color: #64748b; }

/* ── Assignment Table ──────────────────────────────────── */
.assignment-table-wrapper { overflow-x: auto; border-radius: 8px; border: 1px solid #334155; }
.assignment-table { width: 100%; border-collapse: collapse; background: rgba(30,41,59,0.4); }
.assignment-table th {
  padding: 12px 16px; font-size: 0.75rem; font-weight: 600;
  color: #94a3b8; text-align: center; background: #334155;
  border-bottom: 2px solid #475569; white-space: nowrap;
}
.assignment-table th.sticky-col { text-align: left; min-width: 200px; position: sticky; left: 0; background: #334155; z-index: 1; }
.group-col-label { font-size: 0.8rem; }
.group-col-sub { font-size: 0.65rem; color: #64748b; }
.assignment-table td { padding: 10px 16px; border-bottom: 1px solid rgba(51,65,85,0.5); }
.assignment-table td.sticky-col { position: sticky; left: 0; background: #1e293b; z-index: 1; }
.user-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(251,191,36,0.15); color: #fbbf24;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 600; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 500; }
.user-email { font-size: 0.75rem; color: #64748b; }
.check-cell { text-align: center; }
.check-wrapper { cursor: pointer; display: inline-flex; }
.check-wrapper input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: #fbbf24; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; display: inline-block;
}
.badge-success { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.badge-danger { background: rgba(220,38,38,0.15); color: #dc2626; border: 1px solid rgba(220,38,38,0.3); }
.badge-info { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-gold {
  background: #fbbf24; color: #1a365d; border: none;
  padding: 8px 16px; border-radius: 8px; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-gold:hover { background: #f59e0b; }

.btn-secondary {
  background: rgba(30,41,59,0.8); color: #cbd5e1;
  border: 1px solid #475569; padding: 8px 16px; border-radius: 8px;
  font-size: 0.85rem; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-secondary:hover { background: rgba(51,65,85,0.8); color: #f8fafc; }

.btn-danger-small {
  background: transparent; color: #f87171; border: 1px solid rgba(248,113,113,0.3);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.15s; line-height: 1;
}
.btn-danger-small:hover { background: rgba(248,113,113,0.1); color: #fca5a5; }

.btn-icon {
  background: rgba(148,163,184,0.08); border: 1px solid rgba(148,163,184,0.15);
  color: #94a3b8; width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-size: 14px; line-height: 1;
}
.btn-icon:hover { background: rgba(148,163,184,0.18); color: #f8fafc; }
.btn-icon-danger:hover { background: rgba(248,113,113,0.1); color: #f87171; }

.actions-cell { display: flex; gap: 4px; align-items: center; }

/* ── Form Inputs ──────────────────────────────────────────── */
.input-dark {
  background: rgba(15,23,42,0.5); border: 1px solid #475569;
  color: #f8fafc; padding: 8px 12px; border-radius: 6px;
  font-size: 0.85rem; font-family: inherit; transition: border-color 0.2s;
}
.input-dark:focus { outline: none; border-color: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,0.15); }
.input-dark::placeholder { color: #64748b; }
.search-input { width: 240px; }

/* User search dropdown in Zuordnung */
.user-search-dropdown { position: absolute; right: 0; top: calc(100% + 4px); background: #1e293b; border: 1px solid #475569; border-radius: 8px; min-width: 340px; max-height: 300px; overflow-y: auto; z-index: 100; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.user-search-dropdown:empty { display: none; }
.user-search-result { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; gap: 8px; border-bottom: 1px solid #334155; }
.user-search-result:last-child { border-bottom: none; }
.user-search-result:hover { background: #334155; }
.inline-form { display: flex; gap: 8px; align-items: center; }

.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 0.8rem; color: #94a3b8; font-weight: 500; }
.edit-form { display: flex; flex-direction: column; gap: 12px; }

/* ── Detail Expand Row ──────────────────────────────────── */
.detail-expand-row td { padding: 0 !important; border: none !important; }
.detail-card {
  background: rgba(26,54,93,0.3); border: 1px solid #475569;
  padding: 24px; margin: 0 16px 8px;
  border-radius: 0 0 8px 8px;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail-section { display: flex; flex-direction: column; gap: 12px; }

/* ── User Create Form ──────────────────────────────────── */
.user-create-card {
  background: rgba(30,41,59,0.6); border: 1px solid #475569;
  border-radius: 8px; padding: 20px; margin-bottom: 20px;
}
.user-create-card h3 { margin-bottom: 16px; }
.create-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 32px; color: #64748b;
  font-size: 0.9rem; background: rgba(30,41,59,0.3);
  border: 1px dashed #334155; border-radius: 8px;
}

/* ── ExpertMaker Landing (login / denied) ───────────────── */
.em-landing {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1A2F3F;
  color: #ffffff;
  font-family: 'Roboto', system-ui, sans-serif;
}
.em-landing__inner {
  text-align: center;
  max-width: 28rem;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.em-landing__brand {
  font-size: 1.5rem;
  letter-spacing: 0.025em;
  color: #ffffff;
}
.em-landing__brand strong {
  font-weight: 900;
  font-style: italic;
}
.em-landing__brand em {
  font-weight: 300;
  font-style: italic;
}
.em-landing__appname {
  font-size: 1.125rem;
  letter-spacing: 0.15em;
  color: #FCD55B;
  text-transform: uppercase;
  margin-left: 0.375rem;
  font-weight: 400;
}
.em-landing__subtitle {
  color: #94a3b8;
  margin: 0;
  font-size: 1rem;
}
.em-landing__button {
  display: inline-block;
  background: #FCD55B;
  color: #1a365d;
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.em-landing__button:hover { background: #fbbf24; }

/* ── Delete Confirmation Modal ────────────────────────────── */
.delete-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.delete-modal {
  background: #1e293b; border: 1px solid #475569;
  border-radius: 12px; padding: 28px; max-width: 440px; width: 90%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.btn-danger-confirm {
  background: #dc2626; color: #fff; border: none;
  padding: 8px 16px; border-radius: 8px; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-danger-confirm:hover { background: #b91c1c; }
.btn-danger-confirm:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── System Group Columns (Zuordnung) ────────────────────── */
.system-group-col {
  background: rgba(248,113,113,0.05) !important;
  border-left: 2px solid rgba(248,113,113,0.2);
}
.system-label { color: #f87171; }
.system-check { accent-color: #f87171; }

/* ── Apps Page ────────────────────────────────────────────── */
.app-row-link {
  text-decoration: none; color: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.app-row-link:hover { border-color: rgba(251,191,36,0.3); color: inherit; }
.app-row-right { display: flex; align-items: center; gap: 8px; }
.app-row-arrow { color: #64748b; font-size: 1.2rem; margin-left: 4px; }
.badge-system {
  font-size: 0.65rem; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; display: inline-block;
  background: rgba(248,113,113,0.1); color: #f87171;
  border: 1px solid rgba(248,113,113,0.2);
}

/* ── Control Group Options ────────────────────────────────── */
.control-group-options {
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
}
.control-group-check {
  display: flex; align-items: center; gap: 8px;
  color: #cbd5e1; font-size: 0.85rem; cursor: pointer;
}
.control-group-check input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: #f87171; cursor: pointer;
}

/* ── System Row (App Detail) ──────────────────────────────── */
.system-row { border-color: rgba(248,113,113,0.2); }
.system-name { color: #94a3b8; font-style: italic; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
  .main-area { left: 240px; width: calc(100vw - 240px); }
  .main-content { padding: 24px; }
  .detail-grid { grid-template-columns: 1fr; }
  .create-form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-area { left: 0; width: 100vw; }
  .assignment-table-wrapper { font-size: 0.8rem; }
}
