/**
 * ============================================================================
 * DASHBOARD / SPA STYLESHEET
 * FewoBill - Main App Styles (PHASE 1: Gradient Cards)
 * ============================================================================
 * 
 * Voraussetzung: arctic-aurora.css muss vorher geladen sein
 * ============================================================================
 */

/* ==========================================================================
   APP LOADER (Initial Loading Screen)
   ========================================================================== */

#app-loader {
    position: fixed;
    inset: 0;
    background: var(--aa-bg-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

#app-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

#app-loader .loader-logo {
    font-size: 2rem;
    font-weight: 800;
    background: var(--aa-gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
}

#app-loader .loader-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
            var(--aa-primary),
            var(--aa-accent),
            var(--aa-success),
            var(--aa-secondary),
            var(--aa-primary));
    animation: loaderSpin 1.2s linear infinite;
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
}

@keyframes loaderSpin {
    to {
        transform: rotate(360deg);
    }
}

/* APP SHELL */
#app-shell {
    display: none;
    opacity: 0;
}

#app-shell.visible {
    display: block;
    opacity: 1;
}

body {
    margin: 0;
    padding: 0;
    background: var(--aa-bg-body);
    color: var(--aa-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

.aa-main {
    padding-top: 104px;
    min-height: 100vh;
}

.aa-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

.page-header {
    margin-bottom: 40px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--aa-text-primary);
    margin: 0 0 8px 0;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--aa-text-secondary);
    margin: 0;
}

/* ==========================================================================
   STATS GRID - GRADIENT CARDS (EXAKT MOCKUP) 🎯
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card-gradient {
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    border: none;
    border-radius: 20px;
    padding: 28px;
    color: white;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-card-gradient:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.5);
}

.stat-card-gradient .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.stat-card-gradient .stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1;
}

.stat-card-gradient .stat-change {
    font-size: 0.85rem;
    opacity: 0.85;
    font-weight: 500;
}

.stat-card-gradient .stat-change.positive::before {
    content: '↑ ';
}

.stat-card-gradient .stat-change.negative::before {
    content: '↓ ';
}

/* Card 2 - Umsatz (Blue → Light Blue) */
.stat-card-gradient.success {
    background: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.3);
    /* Angepasster Schatten */
}

.stat-card-gradient.success:hover {
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}

/* Card 3 - Auslastung (Purple → Violet) */
.stat-card-gradient.info {
    background: linear-gradient(135deg, #A855F7 0%, #C084FC 100%);
    box-shadow: 0 8px 30px rgba(168, 85, 247, 0.4);
}

.stat-card-gradient.info:hover {
    box-shadow: 0 12px 40px rgba(168, 85, 247, 0.5);
}

/* Card 4 - Rechnungen (Dark Purple → Blue) */
.stat-card-gradient.warning {
    background: linear-gradient(135deg, #7C3AED 0%, #6366F1 100%);
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.4);
}

.stat-card-gradient.warning:hover {
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.5);
}

.stat-card-gradient.warning:hover {
    box-shadow: 0 12px 40px rgba(251, 191, 36, 0.4);
}

/* ==========================================================================
   CONTENT CARDS
   ========================================================================== */
.content-card {
    background: #ffffff;
    border: none !important;
    /* Entferne die Border, sie macht das Design 'hart' */
    border-radius: 24px;
    margin-bottom: 32px;
    /* Ein Schatten, der weit nach außen strahlt (40px) bei sehr geringer Sichtbarkeit */
    box-shadow: 0 10px 40px rgba(124, 58, 237, 0.06),
        0 2px 10px rgba(0, 0, 0, 0.02);
}

/* .content-card {
    background: #ffffff;
    border: none;
    border-radius: 24px;
    overflow: hidden;
    margin-bottom: 32px;
    /* Nutzt jetzt die optimierte Variable aus der aurora.css */
/* box-shadow: var(--aa-shadow-card);
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
box-shadow 0.3s ease;
} */


.content-card:hover {
    transform: translateY(-4px);
    /* Intensiverer Schatten beim Hover */
    box-shadow: 0 20px 50px rgba(124, 58, 237, 0.12);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 32px 12px 32px;
    /* Mehr Padding oben für den Premium-Look */
    border-bottom: none;
    /* Keine störende Linie */
    gap: 12px;
}

.card-title {
    display: flex;
    align-items: center;
    /* WICHTIG: Richtet Icon und Text innerhalb des Titels aus */
    gap: 12px;
    /* Abstand zwischen Icon und Text */
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
    /* Reduzierte Zeilenhöhe für bessere Zentrierung zum Icon */
    margin: 0;
    color: var(--aa-text-primary);
}

.card-title svg,
.card-title [data-lucide] {
    width: 22px;
    /* Etwas größer für bessere Präsenz */
    height: 22px;
    display: block;
    /* Verhindert Descender-Lücken */
    color: var(--aa-primary);
    flex-shrink: 0;
    /* Verhindert Stauchen des Icons */
}

.card-body {
    padding: 28px;
}

.card-body.no-padding {
    padding: 0;
}

/* ==========================================================================
   CHARTS
   ========================================================================== */

.charts-grid {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    /* Umsatz-Chart bekommt mehr Raum */
    gap: 28px;
    /* Größerer Abstand zwischen den Karten */
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
        /* Stacked auf Tablets/Mobile */
    }
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    padding: 10px;
    /* Sicherheitsabstand für die Tooltips */
}

/* ==========================================================================
   EMPTY & LOADING STATES
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--aa-text-muted);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--aa-text-primary);
    margin: 0 0 8px 0;
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--aa-text-muted);
    margin: 0 0 20px 0;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--aa-text-muted);
}

.loading-state p {
    margin-top: 16px;
}

/* ==========================================================================
   ACTIVITY LIST
   ========================================================================== */

.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--aa-border-light);
    transition: all 0.2s ease;
}

.activity-item:hover {
    background: var(--aa-bg-card-hover);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    transition: all 0.3s ease;
}

.activity-icon svg,
.activity-icon [data-lucide] {
    width: 22px;
    height: 22px;
}

/* Gradient Variants (Mockup) */
.activity-icon.violet {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.activity-icon.cyan {
    background: linear-gradient(135deg, #06B6D4 0%, #14B8A6 100%);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.activity-icon.pink {
    background: linear-gradient(135deg, #EC4899 0%, #D946EF 100%);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.activity-icon.purple {
    background: linear-gradient(135deg, #A855F7 0%, #9333EA 100%);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.activity-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-weight: 500;
    color: var(--aa-text-primary);
    margin-bottom: 2px;
}

.activity-meta {
    font-size: 0.85rem;
    color: var(--aa-text-muted);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn svg,
.btn [data-lucide] {
    width: 18px;
    height: 18px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--aa-primary);
    color: white;
    box-shadow: 0 2px 8px var(--aa-primary-glow);
}

.btn-primary:hover {
    background: var(--aa-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--aa-primary-glow);
    text-decoration: none;
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--aa-text-secondary);
}

.btn-ghost:hover {
    background: var(--aa-bg-card-hover);
    color: var(--aa-text-primary);
    text-decoration: none;
}





/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .aa-main {
        padding-top: 80px;
    }

    .aa-content {
        padding: 16px 12px 32px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

/* =========================
   MODAL (RESPONSIVE / MOBILE SAFE)
   ========================= */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal {
    width: min(92vw, 680px);
    max-height: 90vh;
    background: var(--aa-bg-card);
    color: var(--aa-text-primary);
    border-radius: 18px;
    box-shadow: var(--aa-shadow-xl);
    border: 1px solid var(--aa-border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* scrollt im body */
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.12);
}

.modal-body {
    padding: 18px 20px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(124, 58, 237, 0.12);
}

/* Form Layout nur im Modal */
.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal .form-group {
    min-width: 0;
}

.modal .form-input,
.modal textarea {
    width: 100%;
    box-sizing: border-box;
}

/* =========================
   MOBILE = FULLSCREEN SHEET
   ========================= */
@media (max-width: 480px) {
    .modal-backdrop {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .modal {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }

    .modal-footer {
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
    }

    .modal .form-row {
        grid-template-columns: 1fr;
    }
}


/* ==========================================================================
   DARK MODE
   ========================================================================== */

[data-theme="dark"] .content-card {
    border-color: var(--aa-border-light);
}

[data-theme="dark"] .content-card:hover {
    border-color: var(--aa-border-medium);
}