/**
 * Maklerplan Design System — Unified Theme & Components
 * Shared across: Softphone, Dialer, CRM, Dashboard
 */

/* ═══ DESIGN TOKENS ═══ */
:root {
    /* Backgrounds */
    --ds-bg-body: #0f1117;
    --ds-bg-surface: #1a1d2e;
    --ds-bg-card: #1e2030;
    --ds-bg-elevated: #262940;
    --ds-bg-overlay: rgba(0, 0, 0, 0.6);
    --ds-bg-input: rgba(255, 255, 255, 0.06);
    --ds-bg-hover: rgba(255, 255, 255, 0.08);

    /* Text */
    --ds-text: #f1f5f9;
    --ds-text-secondary: #94a3b8;
    --ds-text-muted: #64748b;
    --ds-text-dim: #475569;

    /* Borders */
    --ds-border: #262940;
    --ds-border-light: rgba(255, 255, 255, 0.08);
    --ds-border-focus: #6366f1;

    /* Brand */
    --ds-brand: #e4150c;
    --ds-brand-hover: #c7120a;
    --ds-accent: #6366f1;
    --ds-accent-hover: #4f46e5;

    /* Status Colors */
    --ds-success: #22c55e;
    --ds-warning: #eab308;
    --ds-danger: #ef4444;
    --ds-info: #3b82f6;
    --ds-purple: #8b5cf6;
    --ds-orange: #f97316;

    /* Radii */
    --ds-radius-sm: 6px;
    --ds-radius: 10px;
    --ds-radius-lg: 14px;
    --ds-radius-xl: 20px;
    --ds-radius-full: 9999px;

    /* Shadows */
    --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --ds-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --ds-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --ds-shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Transitions */
    --ds-transition: 0.2s ease;
    --ds-transition-slow: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);

    /* Font */
    --ds-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══ RESET ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--ds-font);
    background: var(--ds-bg-body);
    color: var(--ds-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--ds-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══ UTILITY ═══ */
.hidden { display: none !important; }
.text-muted { color: var(--ds-text-secondary); }
.text-success { color: var(--ds-success); }
.text-danger { color: var(--ds-danger); }
.text-warning { color: var(--ds-warning); }
.text-accent { color: var(--ds-accent); }
.font-mono { font-family: 'Courier New', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══ TOPNAV ═══ */
.ds-topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: rgba(15, 17, 23, 0.95);
    border-bottom: 1px solid var(--ds-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.ds-topnav .nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ds-topnav .nav-logo {
    font-size: 20px;
}

.ds-topnav .nav-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.ds-topnav .nav-subtitle {
    font-size: 12px;
    color: var(--ds-text-muted);
    margin-left: 8px;
}

.ds-topnav .nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ds-topnav .nav-link {
    padding: 6px 12px;
    border-radius: var(--ds-radius-sm);
    font-size: 13px;
    color: var(--ds-text-secondary);
    transition: all var(--ds-transition);
    text-decoration: none;
}

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

.ds-topnav .nav-link.active {
    color: var(--ds-accent);
    background: rgba(99, 102, 241, 0.1);
}

.ds-topnav .nav-link-icon {
    font-size: 14px;
    margin-right: 4px;
}

/* ═══ LOGIN ═══ */
.ds-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d2e 50%, #0f1117 100%);
}

.ds-login-box {
    background: var(--ds-bg-card);
    border-radius: var(--ds-radius-xl);
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--ds-shadow-lg);
    border: 1px solid var(--ds-border-light);
    animation: ds-fadeIn 0.6s var(--ds-transition-slow);
}

@keyframes ds-fadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ds-login-box h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.ds-login-box .subtitle {
    color: var(--ds-text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.ds-login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ds-login-form select,
.ds-login-form input {
    padding: 12px 16px;
    background: var(--ds-bg-input);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    color: var(--ds-text);
    font-size: 14px;
    font-family: var(--ds-font);
    outline: none;
    transition: border-color var(--ds-transition);
}

.ds-login-form input:focus,
.ds-login-form select:focus {
    border-color: var(--ds-border-focus);
}

.ds-login-form button {
    padding: 12px;
    background: var(--ds-brand);
    border: none;
    border-radius: var(--ds-radius);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--ds-font);
    transition: background var(--ds-transition);
}

.ds-login-form button:hover {
    background: var(--ds-brand-hover);
}

.ds-login-error {
    color: var(--ds-danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* ═══ CARDS ═══ */
.ds-card {
    background: var(--ds-bg-card);
    border-radius: var(--ds-radius-lg);
    border: 1px solid var(--ds-border-light);
    padding: 20px;
    transition: border-color var(--ds-transition);
}

.ds-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.ds-card-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══ KPI CARDS ═══ */
.ds-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.ds-kpi {
    background: var(--ds-bg-card);
    border-radius: var(--ds-radius-lg);
    border: 1px solid var(--ds-border-light);
    padding: 18px 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--ds-transition);
}

.ds-kpi:hover {
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--ds-shadow-glow);
}

.ds-kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ds-accent);
    opacity: 0;
    transition: opacity var(--ds-transition);
}

.ds-kpi:hover::before { opacity: 1; }
.ds-kpi.kpi-green::before { background: var(--ds-success); opacity: 1; }
.ds-kpi.kpi-red::before { background: var(--ds-danger); opacity: 1; }
.ds-kpi.kpi-yellow::before { background: var(--ds-warning); opacity: 1; }
.ds-kpi.kpi-blue::before { background: var(--ds-info); opacity: 1; }
.ds-kpi.kpi-orange::before { background: var(--ds-orange); opacity: 1; }

.ds-kpi-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.ds-kpi-value.green { color: var(--ds-success); }
.ds-kpi-value.red { color: var(--ds-danger); }
.ds-kpi-value.yellow { color: var(--ds-warning); }
.ds-kpi-value.blue { color: var(--ds-info); }
.ds-kpi-value.orange { color: var(--ds-orange); }
.ds-kpi-value.purple { color: var(--ds-purple); }
.ds-kpi-value.accent { color: var(--ds-accent); }

.ds-kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.ds-kpi-delta {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 500;
}

/* ═══ TABLE ═══ */
.ds-table-wrap {
    overflow-x: auto;
    border-radius: var(--ds-radius-lg);
    border: 1px solid var(--ds-border-light);
    background: var(--ds-bg-card);
}

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

.ds-table th {
    text-align: left;
    padding: 11px 14px;
    background: var(--ds-bg-elevated);
    color: var(--ds-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color var(--ds-transition);
    position: sticky;
    top: 0;
}

.ds-table th:hover { color: var(--ds-text); }
.ds-table th.sorted { color: var(--ds-accent); }

.ds-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

.ds-table tbody tr {
    cursor: pointer;
    transition: background var(--ds-transition);
}

.ds-table tbody tr:hover { background: rgba(99, 102, 241, 0.04); }
.ds-table tbody tr.selected { background: rgba(99, 102, 241, 0.1); }

/* ═══ BADGES ═══ */
.ds-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--ds-radius-full);
    font-size: 11px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.2px;
    gap: 4px;
}

.ds-badge-sm {
    padding: 1px 7px;
    font-size: 10px;
}

.ds-badge-outline {
    background: transparent;
    border: 1px solid currentColor;
}

/* ═══ BUTTONS ═══ */
.ds-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--ds-radius);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--ds-font);
    cursor: pointer;
    transition: all var(--ds-transition);
    border: 1px solid var(--ds-border);
    background: var(--ds-bg-card);
    color: var(--ds-text);
}

.ds-btn:hover {
    background: var(--ds-bg-hover);
    border-color: var(--ds-text-muted);
}

.ds-btn-primary {
    background: var(--ds-accent);
    border-color: var(--ds-accent);
    color: white;
}

.ds-btn-primary:hover {
    background: var(--ds-accent-hover);
    border-color: var(--ds-accent-hover);
}

.ds-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--ds-danger);
}

.ds-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

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

.ds-btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-sm);
}

/* ═══ INPUTS ═══ */
.ds-input, .ds-select {
    padding: 9px 14px;
    background: var(--ds-bg-input);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    color: var(--ds-text);
    font-size: 13px;
    font-family: var(--ds-font);
    outline: none;
    transition: border-color var(--ds-transition);
}

.ds-input:focus, .ds-select:focus {
    border-color: var(--ds-border-focus);
}

.ds-input::placeholder {
    color: var(--ds-text-muted);
}

.ds-input-lg {
    padding: 11px 16px;
    font-size: 14px;
}

/* ═══ DETAIL PANEL (slide-in) ═══ */
.ds-detail-panel {
    position: fixed;
    top: 52px;
    right: 0;
    width: 440px;
    height: calc(100vh - 52px);
    background: var(--ds-bg-surface);
    border-left: 1px solid var(--ds-border);
    overflow-y: auto;
    padding: 24px;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
}

.ds-detail-panel.open { transform: translateX(0); }

.ds-detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--ds-bg-hover);
    border: 1px solid var(--ds-border-light);
    border-radius: var(--ds-radius-sm);
    color: var(--ds-text-secondary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--ds-transition);
}

.ds-detail-close:hover {
    color: var(--ds-text);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.ds-detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ds-border-light);
}

.ds-detail-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ds-detail-section h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.ds-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

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

.ds-field-value {
    color: var(--ds-text);
    font-weight: 500;
    text-align: right;
    max-width: 60%;
}

/* ═══ FILTER BAR ═══ */
.ds-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ds-filter-bar .ds-input {
    width: 280px;
}

.ds-filter-count {
    font-size: 13px;
    color: var(--ds-text-secondary);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ═══ PAGINATION ═══ */
.ds-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.ds-pagination button {
    padding: 6px 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-bg-card);
    color: var(--ds-text-secondary);
    font-size: 13px;
    font-family: var(--ds-font);
    cursor: pointer;
    transition: all var(--ds-transition);
}

.ds-pagination button:hover {
    border-color: var(--ds-accent);
    color: var(--ds-text);
}

.ds-pagination button.active {
    background: var(--ds-accent);
    border-color: var(--ds-accent);
    color: white;
}

.ds-pagination button:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* ═══ PROGRESS BAR ═══ */
.ds-progress-bg {
    flex: 1;
    height: 8px;
    background: var(--ds-bg-elevated);
    border-radius: var(--ds-radius-full);
    overflow: hidden;
}

.ds-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ds-accent), var(--ds-purple));
    border-radius: var(--ds-radius-full);
    transition: width 0.5s ease;
}

/* ═══ TOAST NOTIFICATIONS ═══ */
.ds-toast-container {
    position: fixed;
    top: 64px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.ds-toast {
    background: var(--ds-bg-card);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    padding: 12px 16px;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: var(--ds-shadow-lg);
    animation: ds-toastIn 0.3s ease forwards;
    pointer-events: auto;
    font-size: 13px;
}

.ds-toast.removing {
    animation: ds-toastOut 0.25s ease forwards;
}

@keyframes ds-toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes ds-toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

.ds-toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.ds-toast-body { flex: 1; }
.ds-toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.ds-toast-msg { color: var(--ds-text-secondary); font-size: 12px; }

.ds-toast.success { border-left: 3px solid var(--ds-success); }
.ds-toast.error { border-left: 3px solid var(--ds-danger); }
.ds-toast.warning { border-left: 3px solid var(--ds-warning); }
.ds-toast.info { border-left: 3px solid var(--ds-info); }

.ds-toast-close {
    background: none;
    border: none;
    color: var(--ds-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    transition: color var(--ds-transition);
}

.ds-toast-close:hover { color: var(--ds-text); }

/* ═══ EMPTY STATE ═══ */
.ds-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--ds-text-muted);
    font-size: 14px;
}

.ds-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.4); }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .ds-topnav .nav-links { display: none; }
    .ds-filter-bar .ds-input { width: 100%; }
    .ds-detail-panel { width: 100%; }
    .ds-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
