/* ============================================================================
   beya CRM — Design-System
   Inspiriert vom Design von beyaconsulting.com
   ============================================================================ */

/* ---- Fonts (selbst-gehostet) ---- */
@font-face {
    font-family: 'Studio Pro';
    src: url('/assets/fonts/StudioPro-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Monument Extended';
    src: url('/assets/fonts/PPMonumentExtended-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ---- Tokens ---- */
:root {
    /* Farben aus beyaconsulting.com */
    --sage:           #8b9a87;
    --sage-light:     #e8ebe7;
    --sage-dark:      #6e7d6a;
    --terracotta:     #d4a574;
    --terracotta-light:#f0e7d9;
    --lavender:       #b8a8c8;
    --lavender-light: #ede8f1;
    --cream:          #f7f6f3;
    --cream-soft:     #fefefe;

    --stone-50:  #f7f6f3;
    --stone-100: #f2f0ed;
    --stone-200: #e8e6e1;
    --stone-300: #d4d1cb;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;

    --white: #ffffff;
    --black: #000000;

    /* Status */
    --status-success: #6e8e6a;
    --status-warning: #d4a574;
    --status-error:   #c0635a;
    --status-info:    #8a9bb0;

    /* Typografie */
    --font-display: 'Monument Extended', 'Studio Pro', system-ui, sans-serif;
    --font-body:    'Studio Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-8: 48px;
    --sp-10: 64px;

    /* Radius / Shadows */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 14px;
    --r-xl: 22px;

    --shadow-1: 0 1px 2px rgba(28,25,23,0.04), 0 1px 3px rgba(28,25,23,0.06);
    --shadow-2: 0 4px 12px rgba(28,25,23,0.06), 0 2px 4px rgba(28,25,23,0.04);
    --shadow-3: 0 10px 30px rgba(28,25,23,0.08);

    /* Layout */
    --sidebar-w: 240px;
    --topbar-h:  64px;
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--stone-900);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--stone-900);
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0 0 var(--sp-4);
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.075rem; }

p { margin: 0 0 var(--sp-3); }

a { color: var(--sage-dark); text-decoration: none; }
a:hover { color: var(--terracotta); text-decoration: underline; text-underline-offset: 3px; }

hr { border: none; border-top: 1px solid var(--stone-200); margin: var(--sp-5) 0; }

/* ---- Layout-Shell ---- */
.layout-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
}

.topbar {
    grid-area: topbar;
    background: var(--white);
    border-bottom: 1px solid var(--stone-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar__search {
    flex: 1;
    max-width: 520px;
    margin-right: var(--sp-6);
}
.topbar__search .input { background: var(--cream); border-color: transparent; }
.topbar__search .input:focus { background: var(--white); border-color: var(--sage); }

.topbar__user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}
.topbar__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--sage);
    color: var(--white);
    font-family: var(--font-display);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.sidebar {
    grid-area: sidebar;
    background: var(--stone-900);
    color: var(--stone-200);
    padding: var(--sp-6) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}
.sidebar__brand {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--cream);
    letter-spacing: -0.02em;
    padding: 0 var(--sp-3) var(--sp-4);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand small {
    display: block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--stone-400);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 4px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__group { color: var(--stone-400); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.nav__link {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--r-md);
    color: var(--stone-200);
    font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
}
.nav__link:hover { background: rgba(255,255,255,0.05); color: var(--white); text-decoration: none; }
.nav__link.is-active { background: var(--sage); color: var(--white); }
.nav__link.is-active:hover { background: var(--sage-dark); }
.nav__icon { width: 18px; height: 18px; opacity: 0.9; flex: none; }

.main {
    grid-area: main;
    padding: var(--sp-6) var(--sp-8);
    overflow-x: auto;
}
.main__header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-5);
    gap: var(--sp-4);
    flex-wrap: wrap;
}
.main__title { margin: 0; }
.main__title-sub { color: var(--stone-500); font-size: 0.92rem; margin-top: 4px; }

/* ---- Cards ---- */
.card {
    background: var(--white);
    border: 1px solid var(--stone-200);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    margin-bottom: var(--sp-5);
}
.card__header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--stone-200);
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-3);
}
.card__title { margin: 0; font-size: 1.05rem; }
.card__body { padding: var(--sp-5); }
.card__footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--stone-200); background: var(--cream); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    padding: 9px 18px;
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 400;
    border: 1px solid transparent;
    background: var(--stone-900);
    color: var(--white);
    cursor: pointer;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
    text-decoration: none !important;
    line-height: 1.2;
}
.btn:hover { background: var(--stone-700); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--sage); color: var(--white); }
.btn-primary:hover { background: var(--sage-dark); }

.btn-accent { background: var(--terracotta); color: var(--white); }
.btn-accent:hover { background: #b8895a; }

.btn-ghost { background: transparent; color: var(--stone-700); border-color: var(--stone-300); }
.btn-ghost:hover { background: var(--cream); color: var(--stone-900); }

.btn-danger { background: #c0635a; color: var(--white); }
.btn-danger:hover { background: #a4544c; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }

.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ---- Forms ---- */
.form-row { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) {
    .form-row--2, .form-row--3 { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
    font-size: 0.82rem;
    color: var(--stone-600);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.form-help { font-size: 0.78rem; color: var(--stone-500); }
.form-error { font-size: 0.82rem; color: #b04030; margin-top: 4px; }

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--stone-200);
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--stone-900);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(139,154,135,0.15);
}
.textarea { min-height: 90px; resize: vertical; }
.input[disabled], .select[disabled] { background: var(--cream); color: var(--stone-500); }

.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: 0.92rem; }
.checkbox input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--sage); }

/* ---- Tables ---- */
.table-wrap { background: var(--white); border: 1px solid var(--stone-200); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; }
.table thead th {
    background: var(--cream);
    color: var(--stone-600);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--stone-200);
}
.table tbody tr { border-top: 1px solid var(--stone-100); }
.table tbody tr:hover { background: var(--cream); }
.table tbody tr:first-child { border-top: none; }
.table td a { color: var(--stone-900); font-weight: 500; }
.table td a:hover { color: var(--terracotta); }
.table .col-actions { text-align: right; white-space: nowrap; }

/* ---- Badges ---- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    background: var(--stone-100);
    color: var(--stone-700);
    line-height: 1.4;
}
.badge--sage       { background: var(--sage-light);       color: var(--sage-dark); }
.badge--terracotta { background: var(--terracotta-light); color: #8a5a30; }
.badge--lavender   { background: var(--lavender-light);   color: #6f5d82; }
.badge--stone      { background: var(--stone-200);        color: var(--stone-700); }
.badge--success    { background: #e1ece0; color: var(--status-success); }
.badge--warning    { background: var(--terracotta-light); color: #8a5a30; }
.badge--error      { background: #f1dad7; color: #8c4239; }

/* ---- Flash ---- */
.flash { margin-bottom: var(--sp-4); border-radius: var(--r-md); padding: 12px 16px; font-size: 0.92rem; border: 1px solid; }
.flash--success { background: #e8efe6; border-color: #bfd2bb; color: #41613d; }
.flash--error   { background: #f5e2df; border-color: #e2b7af; color: #7d3a32; }
.flash--info    { background: var(--sage-light); border-color: #b9c5b5; color: var(--stone-700); }

/* ---- Login-Layout (full screen) ---- */
.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--cream);
}
@media (max-width: 880px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-layout__art { display: none; }
}
.auth-layout__art {
    background: linear-gradient(135deg, var(--sage) 0%, var(--lavender) 60%, var(--terracotta) 100%);
    position: relative;
    overflow: hidden;
}
.auth-layout__art::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18) 0, transparent 40%),
        radial-gradient(circle at 70% 80%, rgba(255,255,255,0.12) 0, transparent 50%);
}
.auth-layout__art-content {
    position: relative;
    z-index: 1;
    color: var(--white);
    padding: var(--sp-10) var(--sp-8);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-layout__art-content h1 { font-size: 2.6rem; color: var(--white); margin-bottom: var(--sp-4); }
.auth-layout__art-content p { opacity: 0.9; max-width: 480px; }

.auth-layout__form {
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-6);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: var(--sp-8);
}
.auth-card h2 { margin-bottom: var(--sp-2); }
.auth-card__sub { color: var(--stone-500); margin-bottom: var(--sp-6); }

/* ---- Pipeline / Kanban ---- */
.pipeline-board {
    display: flex;
    gap: var(--sp-4);
    overflow-x: auto;
    padding-bottom: var(--sp-3);
    margin: 0 calc(-1 * var(--sp-8));
    padding-left: var(--sp-8);
    padding-right: var(--sp-8);
}
.pipeline-column {
    flex: 0 0 280px;
    background: var(--cream-soft);
    border: 1px solid var(--stone-200);
    border-radius: var(--r-lg);
    display: flex; flex-direction: column;
    max-height: calc(100vh - 240px);
}
.pipeline-column__header {
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
    border-bottom: 1px solid var(--stone-200);
    background: var(--white);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.pipeline-column__title { display: flex; align-items: center; justify-content: space-between; }
.pipeline-column__title strong { font-family: var(--font-display); font-weight: 400; font-size: 0.95rem; }
.pipeline-column__title small { color: var(--stone-500); font-size: 0.8rem; }
.pipeline-column__sum { font-size: 0.78rem; color: var(--stone-500); margin-top: 4px; }
.pipeline-column__list {
    padding: var(--sp-3);
    overflow-y: auto;
    flex: 1;
    display: flex; flex-direction: column; gap: var(--sp-3);
    min-height: 80px;
}
.pipeline-column.is-drag-over .pipeline-column__list {
    background: var(--sage-light);
    border-radius: var(--r-md);
}

.pipeline-card {
    background: var(--white);
    border: 1px solid var(--stone-200);
    border-radius: var(--r-md);
    padding: 12px 14px;
    cursor: grab;
    transition: box-shadow 0.15s, transform 0.05s;
    box-shadow: var(--shadow-1);
}
.pipeline-card:hover { box-shadow: var(--shadow-2); }
.pipeline-card:active { cursor: grabbing; }
.pipeline-card.is-dragging { opacity: 0.5; }
.pipeline-card__title { font-weight: 500; color: var(--stone-900); display: block; margin-bottom: 6px; }
.pipeline-card__title:hover { color: var(--terracotta); }
.pipeline-card__meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--stone-500); margin-top: 6px; }
.pipeline-card__value { font-family: var(--font-display); color: var(--sage-dark); font-size: 0.92rem; }

/* ---- Dashboard tiles ---- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.tile {
    background: var(--white);
    border: 1px solid var(--stone-200);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
}
.tile__label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--stone-500); margin-bottom: var(--sp-2); }
.tile__value { font-family: var(--font-display); font-size: 1.95rem; line-height: 1.1; color: var(--stone-900); }
.tile__hint { font-size: 0.82rem; color: var(--stone-500); margin-top: var(--sp-2); }
.tile--sage       { border-top: 3px solid var(--sage); }
.tile--terracotta { border-top: 3px solid var(--terracotta); }
.tile--lavender   { border-top: 3px solid var(--lavender); }
.tile--stone      { border-top: 3px solid var(--stone-400); }

/* ---- Stat bars (Reports) ---- */
.bar-chart { display: flex; flex-direction: column; gap: var(--sp-3); }
.bar-row { display: grid; grid-template-columns: 160px 1fr 80px; gap: var(--sp-3); align-items: center; }
.bar-row__label { font-size: 0.88rem; color: var(--stone-700); }
.bar-row__track { background: var(--stone-100); height: 12px; border-radius: 999px; overflow: hidden; }
.bar-row__fill  { height: 100%; background: linear-gradient(90deg, var(--sage), var(--terracotta)); border-radius: 999px; }
.bar-row__value { font-family: var(--font-display); font-size: 0.92rem; color: var(--stone-700); text-align: right; }

/* ---- Detail page layout ---- */
.detail {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--sp-5);
}
@media (max-width: 980px) {
    .detail { grid-template-columns: 1fr; }
}
.detail__meta {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 10px 16px;
    font-size: 0.92rem;
}
.detail__meta dt { color: var(--stone-500); }
.detail__meta dd { margin: 0; color: var(--stone-900); }

/* ---- Activity timeline ---- */
.timeline { display: flex; flex-direction: column; gap: var(--sp-4); }
.timeline-item { display: grid; grid-template-columns: 40px 1fr; gap: var(--sp-3); }
.timeline-item__icon {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--sage-light); color: var(--sage-dark);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 0.8rem;
}
.timeline-item--call    .timeline-item__icon { background: var(--lavender-light); color: #6f5d82; }
.timeline-item--meeting .timeline-item__icon { background: var(--sage-light);     color: var(--sage-dark); }
.timeline-item--email   .timeline-item__icon { background: var(--terracotta-light); color: #8a5a30; }
.timeline-item--note    .timeline-item__icon { background: var(--stone-200);     color: var(--stone-700); }
.timeline-item__title { font-weight: 500; }
.timeline-item__sub   { font-size: 0.82rem; color: var(--stone-500); margin-top: 2px; }
.timeline-item__body  { font-size: 0.92rem; color: var(--stone-700); margin-top: 6px; white-space: pre-wrap; }

/* ---- Empty state ---- */
.empty {
    text-align: center;
    padding: var(--sp-8) var(--sp-4);
    color: var(--stone-500);
}
.empty__title { color: var(--stone-700); margin-bottom: var(--sp-2); font-family: var(--font-display); }
.empty__hint  { font-size: 0.92rem; margin-bottom: var(--sp-4); }

/* ---- Toolbar (Liste-Header mit Filtern) ---- */
.toolbar { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; align-items: center; }
.toolbar form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.toolbar .input { min-width: 220px; }

/* ---- Helpers ---- */
.flex   { display: flex; }
.flex-1 { flex: 1; }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted   { color: var(--stone-500); }
.text-small   { font-size: 0.85rem; }
.text-right   { text-align: right; }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.w-full { width: 100%; }
.font-display { font-family: var(--font-display); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .layout-shell { grid-template-columns: 1fr; grid-template-rows: var(--topbar-h) auto 1fr;
        grid-template-areas: "topbar" "sidebar" "main"; }
    .sidebar { flex-direction: row; overflow-x: auto; padding: var(--sp-3); gap: var(--sp-3); }
    .sidebar__brand { display: none; }
    .nav { flex-direction: row; gap: var(--sp-2); }
    .nav__group { display: none; }
    .nav__link { white-space: nowrap; padding: 8px 12px; }
    .main { padding: var(--sp-4); }
}
