/* ============================================================
   CRM – Eigenes Design-System
   ============================================================ */

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: #1e293b;
    background: #f1f5f9;
}

/* ── Navbar ─────────────────────────────────────────────── */
.crm-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 1.5rem;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.crm-nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: .3px;
}
.crm-nav-end {
    display: flex;
    align-items: center;
    gap: .875rem;
}
.crm-nav a {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    font-size: .875rem;
    padding: .25rem .5rem;
    border-radius: 4px;
    transition: background .15s;
}
.crm-nav a:hover { background: rgba(255,255,255,.15); }
.crm-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .7rem;
    background: rgba(255,255,255,.2);
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
}
.crm-badge--logout {
    border: none;
    color: inherit;
    cursor: pointer;
    transition: background .15s;
}
.crm-badge--logout:hover {
    background: rgba(255,255,255,.35);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: .2rem 1.125rem;
    margin: 0 0.2rem;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    line-height: 1.5;
    text-decoration: none;
    text-align: center;
}
.btn-danger {
    color: #dc2626;
}

.btn-primary { color: #2563eb; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.form-actions { text-align: right; }
.btn-outline-white {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,.75);
    color: #fff;
    padding: .3rem .8rem;
    font-size: .8rem;
    border-radius: 5px;
}
.btn-outline-white:hover,
.btn-danger:hover,
.btn-primary:hover { background: rgba(255,255,255,.15); }

/* ── Felder ───────────────────────────────────────────── */
.field { margin-bottom: .875rem; }
.field-row { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .875rem; }
.field-row > .field { flex: 1 1 0; min-width: 0; margin-bottom: 0; }
.field-currency-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.field-currency-wrap input { padding-right: 1.75rem; width: 100%; }
.field-currency-wrap .input-suffix { position: absolute; right: .6rem; font-size: .9rem; color: #64748b; pointer-events: none; user-select: none; }
.field-email-wrap              { position: relative; display: flex; align-items: center; width: 100%; }
.field-email-wrap input        { padding-right: 2.2rem; width: 100%; }
.email-icon-btn, .tel-icon-btn, .map-icon-btn { position: absolute; right: .35rem; background: none; border: none; cursor: pointer; color: #64748b; padding: .2rem .35rem; border-radius: 3px; font-size: 1rem; line-height: 1; }
.email-icon-btn:hover          { color: #2563eb; background: #eff6ff; }
.field-tel-wrap                { position: relative; display: flex; align-items: center; width: 100%; }
.field-tel-wrap input          { padding-right: 2.2rem; width: 100%; }
.tel-icon-btn:hover            { color: #16a34a; background: #f0fdf4; }
.field-map-wrap                { position: relative; display: flex; align-items: center; width: 100%; }
.field-map-wrap input          { padding-right: 2.2rem; width: 100%; }
.map-icon-btn:hover            { color: #dc2626; background: #fef2f2; }
.field-combo { position: relative; }
.field-combo .combo-text { width: 100%; }
.combo-list { position: fixed; z-index: 99999; background: #fff; border: 1.5px solid #2563eb; border-radius: 0 0 6px 6px; max-height: 220px; overflow-y: auto; list-style: none; margin: 0; padding: 0; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.combo-list .combo-item { padding: .4rem .75rem; cursor: pointer; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list .combo-item:hover { background: #eff6ff; color: #1d4ed8; }
.field label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .3rem;
}
.field input,
.field select {
    display: block;
    width: 100%;
    padding: .55rem .75rem;
    font-size: .9rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.required-star { color: #dc2626; margin-left: .15em; }
.field--error input,
.field--error select,
.field--error .combo-text { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.15) !important; }

/* ── Globaler Toast ───────────────────────────────────── */
#crm-toast {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    min-width: 280px;
    max-width: 520px;
    padding: .65rem 1.1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease;
    word-break: break-word;
}
#crm-toast.show      { opacity: 1; }
#crm-toast.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
#crm-toast.toast-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }

/* ── Auth-Links ───────────────────────────────────────── */
.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}
.auth-links a {
    font-size: .8125rem;
    color: #2563eb;
    text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }

/* ── Abschnitte ───────────────────────────────────────── */
/* ── crm-modal--table (Tabellen-Ansicht als Overlay-Panel) ─── */
.crm-modal--table {
    width: 90vw;
    max-width: 1100px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.crm-box {
    background: #fff;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    padding: 1.5rem;
}
.crm-box p { margin: .5rem 0 0; font-size: .9rem; color: #475569; }

/* ── Tabellen-Toolbar (Kundenverwaltung) ──────────────────── */
.crm-table-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
    flex-shrink: 0;
}
.crm-table-toolbar .crm-pagination { margin-left: auto; }
.crm-pagination {
    display: flex;
    align-items: center;
    gap: .15rem;
}
.crm-page-info {
    font-size: 1rem;
    color: #475569;
    min-width: 3.5rem;
    text-align: center;
    user-select: none;
}
.btn-icon {
    padding: .45rem 2rem;
    line-height: 1.5;
}
.btn-sm {
    padding: 0 1rem;
    font-size: 1.5rem;
    line-height: 1.5;
}
/* Tabulator-eigene Footer-Pagination ausblenden */
.tabulator-footer { display: none !important; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-admin    { background: #dbeafe; color: #1d4ed8; }
.badge-user     { background: #f1f5f9; color: #64748b; }
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fee2e2; color: #b91c1c; }
.badge-neutral  { background: #f1f5f9; color: #64748b; }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-warning  { background: #fef9c3; color: #a16207; }
.badge-primary  { background: #dbeafe; color: #1d4ed8; }
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }

/* ── Trennlinie ───────────────────────────────────────── */
hr { border: none; border-top: 1px solid #e2e8f0; margin: 1.25rem 0; }
.section-title { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; color: #1e293b; }

/* ── Utility ──────────────────────────────────────────── */
.hidden { display: none; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.text-center { text-align: center; }
.text-muted { font-size: .8125rem; color: #94a3b8; }

.btn-ghost {
    background: #f1f5f9;
    color: #475569;
}
.btn-ghost:hover  { background: #e2e8f0; }
.btn:disabled     { opacity: .4; cursor: not-allowed; }
.btn-destructive {
    background: red;
    color: #fff;
}
.btn-destructive:hover { background: darkred; }

.btn-ok {
    background: green;
    color: #fff;
}
.btn-ok:hover { background: darkgreen; }

/* ── Modal-Dialog ─────────────────────────────────────── */
.crm-modal-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    animation: crm-fade-in .15s ease;
}
.crm-modal-overlay > * {
    pointer-events: auto;
}   
@keyframes crm-fade-in { from { opacity: 0; } to { opacity: 1; } }
.crm-modal {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 1.75rem 1.75rem 1.5rem;
    width: 100%;
    max-width: 380px;
    margin: 1rem;
    overflow: hidden;
    animation: crm-slide-up .15s ease;
}
@keyframes crm-slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.crm-modal--form       { max-width: 460px; overflow: auto; }
.crm-modal--wide       { max-width: 640px; overflow: auto; }
.crm-modal-title {
    position: sticky;
    top: -1.75rem;
    z-index: 10;
    margin: -1.75rem -1.75rem 1.25rem;
    padding: .9rem 3rem .9rem 1.75rem;
    background: #1d4ed8;
    color: #fff;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
    cursor: grab;
    user-select: none;
}
.crm-modal-title:active { cursor: grabbing; }
.crm-drag-close {
    position: absolute;
    right: .875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .2rem;
    transition: color .1s;
}
.crm-drag-close:hover { color: #fff; }
.crm-resize-handle {
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 18px;
    height: 18px;
    cursor: se-resize;
    z-index: 10;
    border-right: 2px solid rgba(0,0,0,.28);
    border-bottom: 2px solid rgba(0,0,0,.28);
    border-radius: 0 0 4px 0;
    transition: border-color .1s;
    /* background-color: #15803d; */
}
.crm-resize-handle:hover { border-color: rgba(0,0,0,.5); }
.crm-modal-msg {
    margin: 0 0 1.5rem;
    font-size: .9375rem;
    color: #1e293b;
    line-height: 1.5;
}
.crm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .625rem;
}

/* ── Tabulator – Integration ins CRM-Design ──────────── */
.tabulator-row.crm-row-selected,
.tabulator-row.crm-row-selected:hover { background: #e2e8f0 !important; }

/* Tabulator Kontextmenü */
.tabulator-menu {
    background:    #fff;
    border:        1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow:    0 4px 16px rgba(0,0,0,.12);
    padding:       .25rem 0;
    min-width:     150px;
    font-size:     .875rem;
    font-family:   inherit;
    z-index:       999999 !important;
}
.tabulator-menu-item {
    padding:     .45rem 1rem;
    cursor:      pointer;
    color:       #1e293b;
    line-height: 1.5;
}
.tabulator-menu-item:hover                           { background: #f1f5f9; }
.tabulator-menu-item .crm-menu-label                 { display: flex; align-items: center; gap: .5rem; }
.tabulator-menu-item .crm-menu-danger                { color: #b91c1c; }
.tabulator-menu-item:has(.crm-menu-danger):hover     { background: #fef2f2; }
#userTableEl .tabulator {
    border: none;
    border-radius: 0;
    font-family: inherit;
    font-size: .875rem;
    background: #fff;
}
#userTableEl .tabulator .tabulator-header {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}
#userTableEl .tabulator .tabulator-header .tabulator-col {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: .6rem .875rem;
}
#userTableEl .tabulator .tabulator-header .tabulator-col .tabulator-col-title {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    color: #64748b;
}
#userTableEl .tabulator .tabulator-row {
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}
#userTableEl .tabulator .tabulator-row:hover {
    background: #f8fafc !important;
}
#userTableEl .tabulator .tabulator-row .tabulator-cell {
    padding: .65rem .875rem;
    border-right: 1px solid #f1f5f9;
}
