/* ═══════════════════════════════════════════
   NexaCore Management Center — Design v2
═══════════════════════════════════════════ */

:root {
    --sidebar-w: 256px;
    --topbar-h: 60px;

    /* Sidebar */
    --sb-bg:       #111827;
    --sb-hover:    rgba(255,255,255,.06);
    --sb-active-bg: rgba(99,102,241,.18);
    --sb-active-bar: #6366f1;
    --sb-text:     #9ca3af;
    --sb-text-hi:  #f3f4f6;

    /* Brand */
    --primary:     #6366f1;
    --primary-d:   #4f46e5;
    --primary-xl:  #eef2ff;

    /* Surface */
    --bg:          #f1f5f9;
    --surface:     #ffffff;
    --surface-2:   #f8fafc;
    --border:      #e2e8f0;
    --border-2:    #f1f5f9;

    /* Text */
    --text:        #0f172a;
    --text-2:      #334155;
    --text-muted:  #64748b;
    --text-faint:  #94a3b8;

    /* Semantics */
    --success:     #16a34a;
    --success-bg:  #f0fdf4;
    --warning:     #d97706;
    --warning-bg:  #fffbeb;
    --danger:      #dc2626;
    --danger-bg:   #fef2f2;
    --info:        #0284c7;
    --info-bg:     #f0f9ff;

    /* Shape */
    --radius:   10px;
    --radius-lg: 14px;
    --shadow:   0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
}

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────── */
.nmc-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    scrollbar-width: none;
}
.nmc-sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    text-decoration: none;
    flex-shrink: 0;
}
.brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 15px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99,102,241,.4);
}
.brand-text { color: #f9fafb; font-weight: 700; font-size: 14px; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub  { color: #6b7280; font-size: 10.5px; font-weight: 400; letter-spacing: .02em; text-transform: uppercase; }

/* Section labels */
.sidebar-section-label {
    padding: 14px 18px 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #4b5563;
}

/* Nav links */
.sidebar-nav { list-style: none; margin: 0; padding: 4px 10px; }
.sidebar-nav li { margin-bottom: 1px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background .12s, color .12s;
    position: relative;
}
.sidebar-nav a:hover { background: var(--sb-hover); color: #d1d5db; }
.sidebar-nav a.active {
    background: var(--sb-active-bg);
    color: #a5b4fc;
    font-weight: 600;
}
.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 6px; bottom: 6px;
    width: 3px;
    background: var(--sb-active-bar);
    border-radius: 0 3px 3px 0;
}
.sidebar-nav a svg { width: 15px; height: 15px; flex-shrink: 0; stroke-width: 1.8; opacity: .75; }
.sidebar-nav a:hover svg, .sidebar-nav a.active svg { opacity: 1; }

.badge-count {
    margin-left: auto;
    background: rgba(99,102,241,.3);
    color: #a5b4fc;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}
.sidebar-nav a.active .badge-count {
    background: rgba(99,102,241,.4);
    color: #c7d2fe;
}

/* Divider */
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 6px 10px;
}

/* Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.user-info {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 8px;
    border-radius: 8px;
    transition: background .12s;
    cursor: default;
}
.user-info:hover { background: rgba(255,255,255,.05); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 12px;
    flex-shrink: 0;
}
.user-name { color: #f3f4f6; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.user-role { color: #6b7280; font-size: 10.5px; margin-top: 1px; }

/* ── Topbar ───────────────────────────────── */
.nmc-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 500;
    gap: 14px;
}
.topbar-title {
    font-weight: 700;
    font-size: 16px;
    margin: 0;
    color: var(--text);
    letter-spacing: -.01em;
}
.topbar-breadcrumb {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-left: 4px;
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-icon-btn {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: none;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
    text-decoration: none;
}
.topbar-icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: #d1d5db;
}
.topbar-icon-btn svg { width: 15px; height: 15px; }
.topbar-clock {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 11px;
}

/* ── Main Content ────────────────────────── */
.nmc-main {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}
.nmc-content { padding: 24px 28px; }

/* ── Cards ───────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-2);
    display: flex; align-items: center; gap: 10px;
    background: none;
}
.card-header h5, .card-header h6, .card-header .card-title {
    margin: 0;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}
.card-body { padding: 18px 20px; }

/* ── Stat Cards ──────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: flex-start; gap: 14px;
    transition: box-shadow .2s, transform .2s;
    overflow: hidden;
    position: relative;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--stat-accent, var(--primary));
    opacity: .6;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.primary  { background: #eef2ff; color: #6366f1; }
.stat-icon.success  { background: #f0fdf4; color: #16a34a; }
.stat-icon.warning  { background: #fffbeb; color: #d97706; }
.stat-icon.danger   { background: #fef2f2; color: #dc2626; }
.stat-icon.info     { background: #f0f9ff; color: #0284c7; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; margin-bottom: 3px; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-delta { font-size: 11.5px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Tables ──────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table { font-size: 13px; margin: 0; }
.table th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    white-space: nowrap;
}
.table td {
    padding: 11px 16px;
    vertical-align: middle;
    border-color: var(--border-2);
    color: var(--text-2);
}
.table tbody tr:hover { background: #fafbff; }
.table tbody tr[onclick] { cursor: pointer; }

/* ── Badges ──────────────────────────────── */
.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 99px;
    letter-spacing: .01em;
}
.status-badge { font-size: 11.5px; }
.badge-open     { background: #dbeafe; color: #1d4ed8; }
.badge-progress { background: #ede9fe; color: #5b21b6; }
.badge-waiting  { background: #fef3c7; color: #92400e; }
.badge-resolved { background: #dcfce7; color: #14532d; }
.badge-closed   { background: #f1f5f9; color: #475569; }

.priority-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.priority-dot.priority-low    { background: #94a3b8; }
.priority-dot.priority-medium { background: #f59e0b; }
.priority-dot.priority-high   { background: #ef4444; }
.priority-dot.priority-urgent { background: #7c3aed; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .65; transform: scale(1.3); }
}

/* ── Forms ───────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text);
    margin-bottom: 5px;
}
.form-control, .form-select {
    font-size: 13.5px;
    border-color: var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.13);
    background: var(--surface);
}
.form-control-sm { font-size: 12.5px; }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
textarea.form-control { line-height: 1.6; }

/* ── Buttons ─────────────────────────────── */
.btn {
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    padding: 7px 15px;
    transition: all .14s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: .01em;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-d);
    border-color: var(--primary-d);
    color: #fff;
}
.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-2);
    background: var(--surface);
}
.btn-outline-secondary:hover {
    border-color: #cbd5e1;
    background: var(--surface-2);
    color: var(--text);
}
.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary-xl);
    border-color: var(--primary);
    color: var(--primary-d);
}
.btn-outline-danger {
    border-color: #fca5a5;
    color: var(--danger);
    background: transparent;
}
.btn-outline-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}
.btn-outline-success {
    border-color: #86efac;
    color: var(--success);
    background: transparent;
}
.btn-outline-success:hover {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}
.btn-outline-warning {
    border-color: #fcd34d;
    color: var(--warning);
    background: transparent;
}
.btn-outline-warning:hover {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: var(--warning);
}
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}
.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
}
.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}
.btn-warning:hover {
    background: #b45309;
    border-color: #b45309;
    color: #fff;
}
.btn-sm { font-size: 12px; padding: 5px 11px; }
.btn-xs { font-size: 11px; padding: 3px 8px; border-radius: 6px; }
.btn-icon { padding: 6px; border-radius: 7px; }
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon.btn-sm { padding: 5px; }
.btn-icon.btn-xs { padding: 3px; }

/* ── Alerts ──────────────────────────────── */
.alert {
    border-radius: 9px;
    font-size: 13.5px;
    border: none;
    padding: 12px 16px;
}
.alert-success { background: #f0fdf4; color: #14532d; border-left: 3px solid #22c55e; }
.alert-danger  { background: #fef2f2; color: #7f1d1d; border-left: 3px solid #ef4444; }
.alert-warning { background: #fffbeb; color: #78350f; border-left: 3px solid #f59e0b; }
.alert-info    { background: #f0f9ff; color: #0c4a6e; border-left: 3px solid #38bdf8; }

/* ── Ticket View ─────────────────────────── */
.ticket-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 18px;
}
.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 10px;
}
.ticket-meta span { display: flex; align-items: center; gap: 5px; }

.ticket-messages { display: flex; flex-direction: column; gap: 14px; }
.ticket-message {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.message-header {
    background: var(--surface-2);
    padding: 11px 20px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-bottom: 1px solid var(--border-2);
    font-size: 13px;
}
.message-body {
    padding: 16px 20px;
    white-space: pre-wrap;
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-2);
}
.ticket-message.internal { border-left: 3px solid #f59e0b; }
.ticket-message.internal .message-header { background: #fffbeb; }
.internal-tag {
    background: #fef3c7;
    color: #92400e;
    border-radius: 99px;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
}

/* ── Störungen ───────────────────────────── */
.stoerung-row { cursor: pointer; }

/* ── Login Page ──────────────────────────── */
.login-page {
    min-height: 100vh;
    background: var(--sb-bg);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,.12) 0%, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.login-logo {
    width: 50px; height: 50px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 22px;
    margin: 0 auto 20px;
    box-shadow: 0 4px 16px rgba(99,102,241,.4);
}
.login-box h1 { font-size: 21px; font-weight: 800; text-align: center; margin-bottom: 4px; letter-spacing: -.02em; }
.login-box p  { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* ── Page Header ─────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }

/* ── Avatar ──────────────────────────────── */
.avatar-sm {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff; font-size: 10.5px; font-weight: 700;
    flex-shrink: 0;
}

/* ── Empty State ─────────────────────────── */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 44px; height: 44px; opacity: .25; margin-bottom: 14px; }
.empty-state h4 { font-size: 15px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── Search & Filter ─────────────────────── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar svg {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Misc Components ─────────────────────── */
.dept-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.progress-thin { height: 4px; border-radius: 99px; }

/* ── Activity Feed ───────────────────────── */
.activity-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-2);
}
.activity-item:last-child { border: none; }
.activity-icon {
    width: 30px; height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}
.activity-text { font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.activity-time { font-size: 11px; color: var(--text-faint); }

/* ── Mail Import ─────────────────────────── */
.mail-item {
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    transition: box-shadow .15s;
}
.mail-item:hover { box-shadow: var(--shadow); }
.mail-item.converted { border-left-color: #22c55e; }
.mail-subject { font-weight: 600; font-size: 13.5px; color: var(--text); }
.mail-from { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
    .nmc-sidebar { transform: translateX(-100%); }
    .nmc-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
    .nmc-main   { margin-left: 0; }
    .nmc-topbar { left: 0; }
    .nmc-content { padding: 16px; }
}

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Utility overrides ───────────────────── */
code {
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 5px;
    color: #7c3aed;
}
hr { border-color: var(--border-2); }
a { color: var(--primary); }
a:hover { color: var(--primary-d); }

/* Bootstrap overrides */
.bg-success-subtle { background: var(--success-bg) !important; }
.bg-warning-subtle { background: var(--warning-bg) !important; }
.bg-danger-subtle  { background: var(--danger-bg) !important; }
.bg-secondary-subtle { background: var(--surface-2) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--text-muted) !important; }
.border-danger { border-color: #fecaca !important; }
