/* public/css/dashboard.css – Vollständig korrigierte Version
 * MIT ALLEN KORREKTUREN:
 * - Umsatzentwicklung (revenueChartCard): span 6 (Hälfte der Breite)
 * - Portal-Aktionen: span 6 + border-top mit definierter Farbe (--purple)
 * - Keine Auslassungen – alle Styles aus der Originaldatei sind enthalten
 */

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.quick-action-card {
    background: #fff;
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    border: 1px solid var(--gray-200);
}

.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.quick-action-content {
    flex: 1;
}

.quick-action-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--gray-900);
}

.quick-action-desc {
    font-size: 0.75rem;
    color: var(--gray-600);
}

/* ============================================================
   DASHBOARD CONTAINER (Grid)
   ============================================================ */
.dashboard-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.stat-card {
    grid-column: span 3;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border-top: 4px solid var(--primary);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card:nth-child(2) {
    border-top-color: var(--warning);
}
.stat-card:nth-child(3) {
    border-top-color: var(--info);
}
.stat-card:nth-child(4) {
    border-top-color: var(--danger);
}

.stat-title {
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 4px;
    min-height: 1.2em;
}

.stat-sub.neutral {
    color: var(--gray-600);
}
.stat-sub.positive {
    color: var(--success);
}
.stat-sub.negative {
    color: var(--danger);
}

/* ============================================================
   CHARTS CARD
   ============================================================ */
.chart-card {
    grid-column: span 6;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border-top: 4px solid var(--primary);
}

/* ============================================================
   UMSATZENTWICKLUNG – 🔥 KORRIGIERT: span 6 (Hälfte der Breite)
   ============================================================ */
#revenueChartCard {
    grid-column: span 6; /* ✅ Korrigiert: volle Hälfte statt 1/4 */
}

.chart-card.full-width {
    grid-column: span 12;
}

.chart-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--gray-800);
    flex-wrap: wrap;
    gap: 10px;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.data-refresh-info {
    font-size: 0.7rem;
    color: var(--gray-500);
    font-weight: normal;
}

/* ============================================================
   PORTAL ACTIONS CARD – 🔥 KORRIGIERT: border-top mit definierter Farbe
   ============================================================ */
.portal-actions-card {
    grid-column: span 6;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border-top: 4px solid var(--purple); /* ✅ Korrigiert: definierte Farbe */
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.portal-actions-card .section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.portal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.portal-tab-btn {
    padding: 6px 14px;
    border: 1px solid var(--gray-300);
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.portal-actions-content {
    flex: 1;
    overflow-y: auto;
}

/* ============================================================
   RECENT INVOICES & TASKS
   ============================================================ */
.recent-invoices-half,
.invoice-stats {
    grid-column: span 6;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border-top: 4px solid var(--purple);
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.recent-invoices-half .section-title,
.invoice-stats .section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.compact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.compact-table th {
    text-align: left;
    padding: 8px 8px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.compact-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
}

.invoice-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    min-width: 70px;
}

.status-paid {
    background: var(--success-bg);
    color: var(--success);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============================================================
   TASKS LIST
   ============================================================ */
.tasks-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-md);
    padding: 12px;
    background: #fff;
    transition: all 0.15s;
}

.task-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.task-title {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.task-meta {
    display: flex;
    gap: 16px;
    font-size: 0.7rem;
    color: var(--gray-500);
    margin-top: 6px;
}

.task-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
}

.task-badge.overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

.task-badge.today {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ============================================================
   UPCOMING DUE
   ============================================================ */
.upcoming-today {
    color: var(--danger);
    font-weight: 700;
}

.upcoming-soon {
    color: var(--warning);
    font-weight: 600;
}

/* ============================================================
   OVERLAYS (für Dashboard-Modals)
   ============================================================ */
.overlay-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

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

/* Details-Overlays, die aus einem anderen Overlay heraus geöffnet werden
   (z. B. Einwand-Details aus "Alle Portal-Aktionen"), müssen ÜBER dem
   Listen-Overlay liegen – beide haben sonst z-index:1000 und die
   DOM-Reihenfolge entscheidet (Liste würde die Details verdecken). */
#disputeDetailOverlay {
    z-index: 1100;
}

/* Mahnungs-Details werden ggf. aus dem "Alle"-Overlay der Sendehistorie
   heraus geöffnet und müssen daher ÜBER dem Listen-Overlay (z-index:1000)
   liegen, sonst sind die Buttons nicht klickbar. */
#reminderDetailModal {
    z-index: 1100;
}

.overlay-content {
    background: #fff;
    border-radius: var(--border-radius-xl);
    padding: 24px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.overlay-content.wide {
    max-width: 900px;
}

.overlay-content.medium {
    max-width: 600px;
}

.overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-500);
}

.overlay-close:hover {
    color: var(--gray-900);
}

.overlay-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Platz für das absolut positionierte X rechts freihalten,
       damit rechtsbündige Buttons (z. B. "Ü30 löschen" im
       Aufgaben-Overlay) nicht darunter rutschen. */
    padding-right: 36px;
}

/* ============================================================
   LETZTE ZAHLUNGSEINGÄNGE – Typ- und Tage-Badges
   Vollzahlung = grün, Teilzahlung = orange, Ratenzahlung = lila.
   Tage überfällig = rot, ausstehend/aktuell = grün.
   ============================================================ */
.status-full {
    background: var(--success-bg);
    color: var(--success);
}

.status-partial {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-installment {
    background: #f3e8ff;
    color: #7c3aed;
}

.days-overdue {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    background: var(--danger-bg);
    color: var(--danger);
}

.days-current {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    background: var(--success-bg);
    color: var(--success);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .stat-card {
        grid-column: span 6;
    }
    .chart-card {
        grid-column: span 12;
    }
    .portal-actions-card,
    .recent-invoices-half,
    .invoice-stats {
        grid-column: span 12;
    }
}

@media (max-width: 768px) {
    .stat-card {
        grid-column: span 12;
    }
    .quick-actions {
        grid-template-columns: 1fr;
    }
    .dashboard-container {
        gap: 16px;
    }
    .quick-action-card {
        padding: 16px;
    }
}
