/* ================================================================
   Auto Inventory — Shared Stylesheet
   Compatible: mobile.de + AutoScout24 modules
   Supports: Light / Dark Mode + Perfex CRM base
   ================================================================ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --ai-bg:          #f5f6fa;
    --ai-bg-card:     #ffffff;
    --ai-bg-header:   #1a1a2e;
    --ai-bg-hover:    #f0f2f8;
    --ai-border:      #e2e8f0;
    --ai-text:        #2d3748;
    --ai-text-muted:  #718096;
    --ai-text-header: #ffffff;
    --ai-green:       #27ae60;
    --ai-yellow:      #f39c12;
    --ai-red:         #e74c3c;
    --ai-blue:        #3498db;
    --ai-purple:      #9b59b6;
    --ai-orange:      #e67e22;
    --ai-radius:      10px;
    --ai-shadow:      0 2px 12px rgba(0,0,0,.08);
    --ai-shadow-card: 0 4px 20px rgba(0,0,0,.06);
    --ai-font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ai-mobile-color:    #0066b2;
    --ai-autoscout-color: #e8521a;
}



/* ── Global Scope ────────────────────────────────────────────────── */
.content { background: var(--ai-bg) !important; }
* { box-sizing: border-box; }

/* ── Header Bar ──────────────────────────────────────────────────── */
.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ai-bg-header);
    padding: 10px 20px;
    border-radius: var(--ai-radius);
    margin-bottom: 16px;
    box-shadow: var(--ai-shadow);
    font-family: var(--ai-font);
    position: sticky;
    top: 0;
    z-index: 100;
}
.ai-logo { display: flex; align-items: center; gap: 10px; }
.ai-logo-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.1);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px;
}
.ai-logo-title {
    display: block; color: #fff;
    font-size: 15px; font-weight: 700;
    letter-spacing: .3px;
}
.ai-logo-source {
    display: inline-block;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: .5px;
    margin-left: 4px;
}
.ai-badge-mobile    { background: var(--ai-mobile-color);    color: #fff; }
.ai-badge-autoscout { background: var(--ai-autoscout-color); color: #fff; }

/* Tabs */
.ai-tabs { display: flex; gap: 4px; }
.ai-tab {
    color: rgba(255,255,255,.6);
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all .18s;
    display: flex; align-items: center; gap: 5px;
}
.ai-tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.ai-tab.active { background: rgba(255,255,255,.15); color: #fff; }
.ai-tab-switch { border: 1px solid rgba(255,255,255,.2); margin-left: 8px; }

/* Right side */
.ai-header-right { display: flex; align-items: center; gap: 12px; }
.ai-live-dot {
    display: flex; align-items: center; gap: 6px;
    color: rgba(255,255,255,.7); font-size: 12px;
}
.ai-live-dot span {
    width: 8px; height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: ai-pulse 1.5s infinite;
}
@keyframes ai-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.3); }
}
.ai-datetime { color: rgba(255,255,255,.6); font-size: 12px; }
.ai-btn-icon {
    background: rgba(255,255,255,.1);
    border: none; border-radius: 7px;
    color: #fff; width: 32px; height: 32px;
    cursor: pointer; transition: background .18s;
    display: flex; align-items: center; justify-content: center;
}
.ai-btn-icon:hover { background: rgba(255,255,255,.2); }

/* ── KPI Row ─────────────────────────────────────────────────────── */
.ai-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.ai-kpi-card {
    background: var(--ai-bg-card);
    border-radius: var(--ai-radius);
    padding: 20px;
    box-shadow: var(--ai-shadow-card);
    border: 1px solid var(--ai-border);
    position: relative;
    overflow: hidden;
    font-family: var(--ai-font);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-kpi-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--ai-text-muted);
    text-transform: uppercase;
}
.ai-kpi-value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--ai-text);
}
.ai-kpi-sub {
    font-size: 12px;
    color: var(--ai-text-muted);
}
.ai-kpi-tags { margin-top: 6px; }
.ai-kpi-tag-row {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    padding: 3px 0;
    color: var(--ai-text-muted);
    border-bottom: 1px solid var(--ai-border);
}
.ai-kpi-tag-row:last-child { border-bottom: none; }
.ai-kpi-chart-wrap { margin-top: auto; padding-top: 10px; }

/* ── Color Utilities ─────────────────────────────────────────────── */
.ai-color-green  { color: var(--ai-green) !important; }
.ai-color-yellow { color: var(--ai-yellow) !important; }
.ai-color-red    { color: var(--ai-red) !important; }
.ai-color-blue   { color: var(--ai-blue) !important; }
.ai-color-purple { color: var(--ai-purple) !important; }
.ai-color-orange { color: var(--ai-orange) !important; }

/* ── Panels ──────────────────────────────────────────────────────── */
.ai-main-row {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    margin-bottom: 16px;
}
.ai-panel {
    background: var(--ai-bg-card);
    border-radius: var(--ai-radius);
    border: 1px solid var(--ai-border);
    box-shadow: var(--ai-shadow-card);
    font-family: var(--ai-font);
    overflow: hidden;
}
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ai-border);
}
.ai-panel-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ai-text);
    letter-spacing: .2px;
}
.ai-panel-body { padding: 16px 20px; }

/* Badges */
.ai-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.ai-badge-new     { background: rgba(39,174,96,.15); color: var(--ai-green); }
.ai-badge-today   { background: rgba(243,156,18,.15); color: var(--ai-yellow); }
.ai-badge-count   { background: rgba(52,152,219,.12); color: var(--ai-blue); text-decoration: none; }

/* ── Chance Items ────────────────────────────────────────────────── */
.ai-chance-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ai-border);
    transition: background .15s;
}
.ai-chance-item:last-child { border-bottom: none; }
.ai-chance-item:hover { background: var(--ai-bg-hover); margin: 0 -20px; padding: 12px 20px; }
.ai-chance-icon { font-size: 18px; width: 26px; text-align: center; }
.ai-chance-info { flex: 1; min-width: 0; }
.ai-chance-title a {
    color: var(--ai-text);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: block;
}
.ai-chance-title a:hover { color: var(--ai-blue); }
.ai-chance-sub { font-size: 11.5px; color: var(--ai-text-muted); margin-top: 2px; }
.ai-chance-price { text-align: right; min-width: 120px; }
.ai-price-delta { display: block; font-size: 14px; font-weight: 700; }
.ai-price-label { font-size: 11px; color: var(--ai-text-muted); }

/* Dark mode fixes for chance items */
.ai-btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: var(--ai-bg-hover);
    border-radius: 6px;
    font-size: 12px;
    color: var(--ai-text);
    text-decoration: none;
    border: 1px solid var(--ai-border);
    transition: all .15s;
    white-space: nowrap;
    cursor: pointer;
}
.ai-btn-sm:hover { background: var(--ai-blue); color: #fff !important; border-color: var(--ai-blue); }

/* Dark mode: kleine Buttons lesbar */
    background: #1e2a3a;
    border-color: #3d5070;
    color: #c8d8f0 !important;
}
    background: var(--ai-blue);
    color: #fff !important;
    border-color: var(--ai-blue);
}

/* ── Alert Timeline ──────────────────────────────────────────────── */
.ai-timeline { max-height: 280px; overflow-y: auto; }
.ai-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--ai-border);
    font-size: 12px;
    color: var(--ai-text-muted);
}
.ai-alert-item:last-child { border-bottom: none; }
.ai-alert-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}
.ai-dot-green  { background: var(--ai-green); }
.ai-dot-yellow { background: var(--ai-yellow); }
.ai-dot-red    { background: var(--ai-red); }
.ai-dot-blue   { background: var(--ai-blue); }
.ai-alert-text { flex: 1; line-height: 1.4; color: var(--ai-text); }
.ai-alert-time { color: var(--ai-text-muted); font-size: 10.5px; white-space: nowrap; }

/* ── Table ───────────────────────────────────────────────────────── */
.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: var(--ai-font);
}
.ai-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--ai-text-muted);
    border-bottom: 2px solid var(--ai-border);
}
.ai-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--ai-border);
    color: var(--ai-text);
    vertical-align: middle;
}
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-table tbody tr:hover td { background: var(--ai-bg-hover); }
.ai-table-link {
    color: var(--ai-text);
    text-decoration: none;
    font-weight: 600;
}
.ai-table-link:hover { color: var(--ai-blue); }
.ai-days { font-weight: 600; }

/* ── Quick Actions ───────────────────────────────────────────────── */
.ai-quick-actions { display: flex; flex-direction: column; gap: 8px; }
.ai-quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: var(--ai-bg);
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    color: var(--ai-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
}
.ai-quick-btn:hover {
    background: var(--ai-blue);
    color: #fff !important;
    border-color: var(--ai-blue);
}
.ai-quick-btn:hover i { color: #fff !important; }

/* Dark mode: Quick Action Buttons gut lesbar */
    background: #1e2a3a;
    border-color: #3d5070;
    color: #c8d8f0 !important;
}
    background: var(--ai-blue);
    color: #fff !important;
    border-color: var(--ai-blue);
}

/* ── Liquidity Bars ──────────────────────────────────────────────── */
.ai-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ai-text-muted);
    margin-bottom: 12px;
}
.ai-liquidity-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.ai-liquidity-label { font-size: 12px; color: var(--ai-text); width: 100px; flex-shrink: 0; }
.ai-liquidity-bar-wrap {
    flex: 1; height: 6px;
    background: var(--ai-border);
    border-radius: 3px; overflow: hidden;
}
.ai-liquidity-bar {
    height: 100%; border-radius: 3px;
    transition: width .6s ease;
}
.ai-liquidity-val { font-size: 11.5px; font-weight: 700; width: 60px; text-align: right; }

/* ── Empty State ─────────────────────────────────────────────────── */
.ai-empty {
    text-align: center; padding: 40px 20px;
    color: var(--ai-text-muted);
}
.ai-empty i { margin-bottom: 12px; opacity: .3; }
.ai-empty p { margin-bottom: 16px; }

/* ── Import Page ─────────────────────────────────────────────────── */
.ai-import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.ai-upload-zone {
    border: 2px dashed var(--ai-border);
    border-radius: var(--ai-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    color: var(--ai-text-muted);
}
.ai-upload-zone:hover, .ai-upload-zone.drag-over {
    border-color: var(--ai-blue);
    background: rgba(52,152,219,.05);
    color: var(--ai-blue);
}
.ai-upload-zone i { font-size: 32px; margin-bottom: 10px; }

.ai-mapping-table { width: 100%; font-size: 13px; }
.ai-mapping-table th { text-align: left; padding: 8px; color: var(--ai-text-muted); font-size: 11px; text-transform: uppercase; }
.ai-mapping-table td { padding: 6px 8px; border-top: 1px solid var(--ai-border); }
.ai-mapping-table select { width: 100%; padding: 4px; border-radius: 4px; border: 1px solid var(--ai-border); background: var(--ai-bg-card); color: var(--ai-text); font-size: 12px; }

.ai-import-log { margin-top: 20px; }
.ai-log-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: 7px;
    background: var(--ai-bg);
    margin-bottom: 6px;
    font-size: 12.5px;
    border: 1px solid var(--ai-border);
}
.ai-log-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ai-log-status-success { background: var(--ai-green); }
.ai-log-status-error   { background: var(--ai-red); }
.ai-log-status-partial { background: var(--ai-yellow); }
.ai-log-info { flex: 1; }
.ai-log-time { color: var(--ai-text-muted); font-size: 11px; }

/* ── Progress Bar ────────────────────────────────────────────────── */
.ai-progress {
    height: 6px; background: var(--ai-border);
    border-radius: 3px; overflow: hidden; margin: 8px 0;
}
.ai-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ai-blue), var(--ai-purple));
    border-radius: 3px;
    transition: width .4s ease;
    animation: ai-progress-shine 1.5s infinite;
}
@keyframes ai-progress-shine {
    0% { opacity: .8; }
    50% { opacity: 1; }
    100% { opacity: .8; }
}

/* ── Vehicle Cards (Portal) ──────────────────────────────────────── */
.ai-vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.ai-vehicle-card {
    background: var(--ai-bg-card);
    border-radius: var(--ai-radius);
    border: 1px solid var(--ai-border);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
}
.ai-vehicle-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.ai-vehicle-card-img {
    width: 100%; height: 190px;
    object-fit: cover;
    background: var(--ai-bg-hover);
    display: flex; align-items: center; justify-content: center;
    color: var(--ai-text-muted);
    font-size: 32px;
}
.ai-vehicle-card-img img { width: 100%; height: 190px; object-fit: cover; }
.ai-vehicle-card-body { padding: 14px; }
.ai-vehicle-card-title {
    font-size: 14px; font-weight: 700; color: var(--ai-text);
    margin-bottom: 4px;
}
.ai-vehicle-card-sub {
    font-size: 12px; color: var(--ai-text-muted); margin-bottom: 10px;
}
.ai-vehicle-card-price {
    font-size: 18px; font-weight: 800; color: var(--ai-text);
}
.ai-vehicle-card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-tag {
    font-size: 11px; padding: 3px 8px;
    border-radius: 20px;
    background: var(--ai-bg);
    border: 1px solid var(--ai-border);
    color: var(--ai-text-muted);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .ai-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .ai-main-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .ai-kpi-row { grid-template-columns: 1fr; }
    .ai-header { flex-wrap: wrap; gap: 10px; }
    .ai-tabs { overflow-x: auto; }
    .ai-import-grid { grid-template-columns: 1fr; }
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.ai-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--ai-border);
    border-top-color: var(--ai-blue);
    border-radius: 50%;
    animation: ai-spin .7s linear infinite;
    margin: 20px auto;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* ── Notification Toast ──────────────────────────────────────────── */
.ai-toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s;
    pointer-events: none;
}
.ai-toast.show { opacity: 1; transform: translateY(0); }
.ai-toast-success { background: var(--ai-green); }
.ai-toast-error   { background: var(--ai-red); }
.ai-toast-info    { background: var(--ai-blue); }

/* ── Source Indicator in combined mode ────────────────────────────── */
.ai-source-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}
.ai-source-mobile    { background: rgba(0,102,178,.12); color: var(--ai-mobile-color); }
.ai-source-autoscout { background: rgba(232,82,26,.12);  color: var(--ai-autoscout-color); }
.ai-source-csv       { background: rgba(39,174,96,.12);  color: var(--ai-green); }

/* ── Settings ────────────────────────────────────────────────────── */
.ai-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-form-group { margin-bottom: 16px; }
.ai-form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ai-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}
.ai-form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--ai-border);
    border-radius: 7px;
    background: var(--ai-bg-card);
    color: var(--ai-text);
    font-size: 13.5px;
    transition: border-color .15s;
    font-family: var(--ai-font);
}
.ai-form-input:focus {
    outline: none;
    border-color: var(--ai-blue);
    box-shadow: 0 0 0 3px rgba(52,152,219,.12);
}

/* Dark mode: Formularfelder gut lesbar */
    background: #1e2a3a !important;
    color: #e2e8f0 !important;
    border-color: #3d5070 !important;
}
    color: #6b7fa0 !important;
}
    background: #1e2a3a;
    color: #e2e8f0;
}

/* API key masked */
.ai-api-key-wrap { position: relative; }
.ai-api-key-wrap .ai-form-input { padding-right: 40px; font-family: monospace; letter-spacing: 1px; }
.ai-api-key-toggle {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--ai-text-muted); cursor: pointer;
}
