/* ============================================================
   VAK-Manager – Stylesheet
   Freundlich & farbenfroh, angelehnt an Trello/Asana
   ============================================================ */

/* --- CSS-Variablen ----------------------------------------- */
:root {
  --c-bg:          #F0F4FF;
  --c-bg-card:     #FFFFFF;
  --c-bg-sidebar:  #1E2A4A;
  --c-primary:     #4361EE;
  --c-primary-d:   #3451D1;
  --c-accent:      #F72585;
  --c-success:     #06D6A0;
  --c-warning:     #FFB703;
  --c-danger:      #EF233C;
  --c-text:        #1A1F3A;
  --c-text-muted:  #7B8AB8;
  --c-border:      #DDE3F5;
  --c-nav-bg:      #FFFFFF;
  --c-nav-shadow:  0 2px 12px rgba(67,97,238,.12);

  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;

  --shadow-card:   0 2px 16px rgba(67,97,238,.10);
  --shadow-hover:  0 8px 32px rgba(67,97,238,.18);

  --font-head:     'Nunito', sans-serif;
  --font-body:     'Inter', sans-serif;

  --nav-h:         64px;
}

/* --- Reset & Basis ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; }

/* --- Navbar ------------------------------------------------- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--c-nav-bg);
  box-shadow: var(--c-nav-shadow);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}
.navbar-brand {
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--font-head);
  font-weight: 800; font-size: 1.25rem;
  color: var(--c-primary);
  text-decoration: none;
}
.brand-icon { font-size: 1.4rem; }
.brand-name { letter-spacing: -.5px; }
.navbar-center { flex: 1; display: flex; justify-content: center; }
.org-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--c-bg); border: 1.5px solid var(--c-border);
  border-radius: 999px; padding: .3rem .9rem;
  font-size: .85rem; font-weight: 600; color: var(--c-text-muted);
}
.org-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-success); display: inline-block;
}
.navbar-right { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.nav-link {
  padding: .4rem .8rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; color: var(--c-text-muted);
  white-space: nowrap; transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-link:hover, .nav-link.active {
  background: var(--c-bg); color: var(--c-primary);
  text-decoration: none;
}

/* User-Menu */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: .4rem;
  background: none; border: 1.5px solid var(--c-border);
  border-radius: 999px; padding: .3rem .75rem .3rem .4rem;
  cursor: pointer; font-family: var(--font-body);
  font-size: .875rem; font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
}
.user-menu-btn:hover { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(67,97,238,.12); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.chevron { font-size: .7rem; color: var(--c-text-muted); }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md); min-width: 220px;
  box-shadow: var(--shadow-hover); z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.dropdown-header {
  padding: .75rem 1rem; font-size: .85rem;
  background: var(--c-bg); border-bottom: 1px solid var(--c-border);
  color: var(--c-text-muted); line-height: 1.5;
}
.dropdown-item {
  display: block; padding: .6rem 1rem; font-size: .9rem;
  color: var(--c-text); transition: background .12s;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--c-bg); text-decoration: none; }
.dropdown-item--danger { color: var(--c-danger); }
.dropdown-divider { border-top: 1px solid var(--c-border); }

/* --- Main Content ------------------------------------------- */
.main-content { flex: 1; padding: 2rem 1.5rem; max-width: 1400px; margin: 0 auto; width: 100%; }

/* --- Flash Messages ----------------------------------------- */
.flash {
  padding: .85rem 1.25rem; border-radius: var(--radius-md);
  margin-bottom: 1rem; font-size: .9rem; font-weight: 500;
}
.flash-success { background: #D1FAF0; color: #065F46; border: 1.5px solid #06D6A0; }
.flash-error   { background: #FEE2E2; color: #7F1D1D; border: 1.5px solid #EF233C; }
.flash-info    { background: #DBEAFE; color: #1E3A8A; border: 1.5px solid #4361EE; }

/* --- Cards -------------------------------------------------- */
.card {
  background: var(--c-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1.5px solid var(--c-border);
  padding: 1.5rem;
}
.card-title {
  font-family: var(--font-head);
  font-size: 1.1rem; font-weight: 800;
  color: var(--c-text); margin-bottom: 1rem;
}

/* --- Buttons ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .875rem;
  font-weight: 600; cursor: pointer; border: none;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn-primary   { background: var(--c-primary);  color: #fff; }
.btn-primary:hover { background: var(--c-primary-d); }
.btn-success   { background: var(--c-success);  color: #fff; }
.btn-danger    { background: var(--c-danger);   color: #fff; }
.btn-outline   { background: transparent; color: var(--c-primary); border: 1.5px solid var(--c-primary); }
.btn-outline:hover { background: var(--c-primary); color: #fff; }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-ghost     { background: transparent; color: var(--c-text-muted); border: 1.5px solid var(--c-border); }
.btn-ghost:hover { border-color: var(--c-primary); color: var(--c-primary); background: transparent; }

/* --- Forms -------------------------------------------------- */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; margin-bottom: .4rem; font-size: .875rem; font-weight: 600; }
.form-control {
  width: 100%; padding: .6rem .9rem;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .9rem; color: var(--c-text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}
select.form-control { cursor: pointer; }

/* --- Auth-Seiten -------------------------------------------- */
.auth-page {
  min-height: calc(100vh - var(--nav-h));
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.auth-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover); border: 1.5px solid var(--c-border);
  padding: 2.5rem; width: 100%; max-width: 420px;
}
.auth-card h1 {
  font-family: var(--font-head); font-size: 1.6rem;
  font-weight: 800; margin-bottom: .25rem; text-align: center;
}
.auth-card .auth-sub {
  color: var(--c-text-muted); font-size: .875rem;
  text-align: center; margin-bottom: 1.75rem;
}
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--c-text-muted); }

/* --- Page Header -------------------------------------------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 {
  font-family: var(--font-head); font-size: 1.5rem; font-weight: 800;
}
.page-header p { color: var(--c-text-muted); font-size: .9rem; margin-top: .2rem; }

/* --- Organigramm -------------------------------------------- */
.org-wrapper { overflow-x: auto; padding-bottom: 1rem; }
.org-tree {
  display: flex; flex-direction: column; align-items: center;
  gap: 0; min-width: max-content; padding: 1rem;
}
.org-level { display: flex; gap: 1.25rem; justify-content: center; position: relative; }
.org-node-wrap {
  display: flex; flex-direction: column; align-items: center;
}
.org-connector-top {
  width: 2px; height: 28px; background: var(--c-border);
}
.org-connector-line {
  height: 2px; background: var(--c-border);
  position: absolute; top: 0; left: 0; right: 0;
}
.org-node {
  background: #fff; border-radius: var(--radius-md);
  border-top: 4px solid var(--c-primary);
  box-shadow: var(--shadow-card);
  padding: .85rem 1.1rem; min-width: 160px; max-width: 200px;
  cursor: pointer; transition: all .2s; text-align: center;
  border-left: 1.5px solid var(--c-border);
  border-right: 1.5px solid var(--c-border);
  border-bottom: 1.5px solid var(--c-border);
}
.org-node:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.org-node-title {
  font-family: var(--font-head); font-size: .9rem; font-weight: 800;
  color: var(--c-text); line-height: 1.3;
}
.org-node-person {
  font-size: .78rem; color: var(--c-text-muted);
  margin-top: .3rem;
}
.org-node-person.vacant { color: var(--c-warning); font-style: italic; }
.org-children {
  display: flex; gap: 1.25rem;
  justify-content: center; position: relative;
}
.org-children-connector {
  display: flex; flex-direction: column; align-items: center;
}
.org-horiz-bar {
  height: 2px; background: var(--c-border);
  position: absolute; top: 0;
}

/* --- VAK-Tabelle -------------------------------------------- */
.vak-section { margin-bottom: 2rem; }
.vak-table-wrapper { overflow-x: auto; }
.vak-table {
  width: 100%; border-collapse: collapse;
  font-size: .9rem; background: #fff;
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-card);
}
.vak-table th {
  background: var(--c-primary); color: #fff;
  font-family: var(--font-head); font-weight: 700;
  padding: .75rem 1rem; text-align: left; font-size: .85rem;
}
.vak-table td {
  padding: .6rem 1rem; border-bottom: 1px solid var(--c-border);
  vertical-align: top; line-height: 1.5;
}
.vak-table tr:last-child td { border-bottom: none; }
.vak-table .area-cell {
  font-weight: 700; font-family: var(--font-head);
  background: var(--c-bg); color: var(--c-primary);
  border-right: 3px solid var(--c-primary);
  min-width: 160px;
}
.vak-table .task-cell {
  font-weight: 600; min-width: 180px;
  border-right: 2px solid var(--c-border);
}
.vak-table .comp-cell { color: var(--c-text-muted); }

/* Drag-Handle */
.drag-handle {
  cursor: grab; color: var(--c-border); font-size: 1rem;
  margin-right: .4rem; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; background: #EEF2FF !important; }
.sortable-drag   { box-shadow: var(--shadow-hover); }

/* --- Inline-Edit -------------------------------------------- */
.editable {
  cursor: pointer; border-radius: 4px;
  padding: 2px 4px; transition: background .15s;
}
.editable:hover { background: #EEF2FF; }
.editable-input {
  border: 1.5px solid var(--c-primary) !important;
  border-radius: 4px; padding: .3rem .5rem;
  font-family: inherit; font-size: inherit;
  width: 100%; outline: none; background: #fff;
  color: #1A1F3A !important;
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
  resize: none; overflow: hidden;
}

/* --- Mitglieder-Liste --------------------------------------- */
.member-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.member-card {
  background: #fff; border-radius: var(--radius-md);
  border: 1.5px solid var(--c-border); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: .85rem;
  box-shadow: var(--shadow-card);
}
.member-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 700; font-size: .95rem; }
.member-email { font-size: .8rem; color: var(--c-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 999px; font-size: .75rem; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase;
}
.role-admin  { background: #FEF3C7; color: #92400E; }
.role-editor { background: #DBEAFE; color: #1E40AF; }
.role-viewer { background: #F0FDF4; color: #166534; }

/* --- Positions-Seite --------------------------------------- */
.positions-list { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.position-item {
  background: #fff; border-radius: var(--radius-md);
  border: 1.5px solid var(--c-border);
  border-left: 4px solid var(--c-primary);
  padding: .9rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-card); cursor: grab;
}
.position-item .pos-color { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.position-item .pos-title { font-weight: 700; flex: 1; }
.position-item .pos-person { font-size: .85rem; color: var(--c-text-muted); }
.position-item .pos-actions { display: flex; gap: .4rem; }

/* --- Modal -------------------------------------------------- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(30,42,74,.45); z-index: 1000;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; padding: 2rem;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.95) translateY(8px); opacity: 0; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-family: var(--font-head); font-size: 1.2rem; font-weight: 800; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--c-text-muted); line-height: 1;
  padding: .2rem .4rem; border-radius: 4px;
}
.modal-close:hover { background: var(--c-bg); }

/* --- Org-Select-Seite -------------------------------------- */
.org-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}
.org-card {
  background: #fff; border-radius: var(--radius-md);
  border: 1.5px solid var(--c-border); padding: 1.5rem;
  box-shadow: var(--shadow-card); cursor: pointer;
  transition: all .2s; text-decoration: none; color: var(--c-text);
  display: flex; flex-direction: column; gap: .5rem;
}
.org-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); border-color: var(--c-primary); text-decoration: none; }
.org-card-name { font-family: var(--font-head); font-size: 1.1rem; font-weight: 800; }
.org-card-role { font-size: .8rem; }

/* --- VAK-Editor -------------------------------------------- */
.vak-editor { margin-top: 1rem; }
.vak-add-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--c-primary); font-size: .875rem; font-weight: 600;
  cursor: pointer; padding: .4rem .6rem; border-radius: var(--radius-sm);
  transition: background .15s; border: none; background: none;
}
.vak-add-btn:hover { background: #EEF2FF; }

/* --- Responsive --------------------------------------------- */
@media (max-width: 768px) {
  .main-content { padding: 1rem; }
  .navbar { padding: 0 1rem; }
  .nav-link { display: none; }
  .org-node { min-width: 120px; padding: .6rem .75rem; }
  .vak-table { font-size: .8rem; }
  .vak-table th, .vak-table td { padding: .5rem .6rem; }
}

/* --- Utilities ---------------------------------------------- */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }
.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: .85rem; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }

/* --- Site Footer -------------------------------------------- */
.site-footer {
  text-align: center; padding: 1rem; font-size: .8rem;
  color: var(--c-text-muted); border-top: 1px solid var(--c-border);
  background: #fff;
}

/* --- Color Chips -------------------------------------------- */
.color-picker-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.color-chip {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: border-color .15s;
}
.color-chip.selected, .color-chip:hover { border-color: #1A1F3A; }
