/* ============================================================
   GDD CRM – Design-System (Dark-Theme)
   ============================================================ */

/* ── CSS-Variablen ─────────────────────────────────────────── */
:root {
    --bg:       #0f172a;
    --surface:  #1e293b;
    --surface2: #334155;
    --border:   rgba(255, 255, 255, 0.07);

    --green:  #2ecc71;
    --amber:  #f59e0b;
    --red:    #ef4444;
    --blue:   #38bdf8;
    --purple: #a78bfa;

    --text:       #f1f5f9;
    --text-muted: #94a3b8;

    --font:   'Inter', system-ui, -apple-system, sans-serif;
    --radius: 6px;
    --sidebar-width: 220px;
}

/* ── Reset & Basis ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── App-Layout (Sidebar + Content) ───────────────────────── */
body:not(.login-page) {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.sidebar-brand small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 3px;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 8px 0;
}

.sidebar-nav li {
    margin: 1px 8px;
}

.nav-link {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.nav-link:hover {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--blue);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.user-role-text {
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: capitalize;
}

/* ── Hauptinhalt ───────────────────────────────────────────── */
.main-content {
    padding: 28px 32px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Seitenkopf ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.page-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--blue);
    color: #0f172a;
    border-color: var(--blue);
}

.btn-primary:hover {
    background: #7dd3fc;
    border-color: #7dd3fc;
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ── Tabellen ──────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--surface2);
}

tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    color: var(--text);
}

.table-muted {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Status-Badges ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-green  { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.badge-amber  { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge-red    { background: rgba(239, 68, 68, 0.15);  color: var(--red); }
.badge-blue   { background: rgba(56, 189, 248, 0.15); color: var(--blue); }
.badge-muted  { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }

/* ── Panels / Cards ────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2,
.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.panel-body {
    padding: 20px;
}

/* ── KPI-Kacheln (Dashboard) ───────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
}

.kpi-green  { color: var(--green); }
.kpi-blue   { color: var(--blue); }
.kpi-amber  { color: var(--amber); }
.kpi-red    { color: var(--red); }

/* ── Formulare ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover {
    background: var(--surface2);
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ── Alerts / Flash-Messages ───────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.2);
    color: var(--green);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--amber);
}

.alert-info {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.2);
    color: var(--blue);
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    margin-left: auto;
    color: inherit;
    opacity: 0.6;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

/* ── Login-Seite ───────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 16px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Filter-Leiste ─────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 6px 10px;
    outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus {
    border-color: var(--blue);
}

/* ── Timeline / Aktivitäten ────────────────────────────────── */
.timeline {
    list-style: none;
    padding: 0;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    margin-top: 5px;
}

.timeline-dot-green  { background: var(--green); }
.timeline-dot-blue   { background: var(--blue); }
.timeline-dot-amber  { background: var(--amber); }
.timeline-dot-red    { background: var(--red); }

.timeline-content {
    flex: 1;
}

.timeline-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Divider ───────────────────────────────────────────────── */
hr.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-amber   { color: var(--amber); }
.text-blue    { color: var(--blue); }
.text-sm      { font-size: 12px; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-mono    { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 12px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 24px; }

.d-flex          { display: flex; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.flex-1          { flex: 1; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 20px;
    font-size: 14px;
}
