/**
 * CarouselView Component Styles
 * 3-Card Focus Carousel with smooth animations
 */

/* ===== Container ===== */
.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow: hidden;
}

/* ===== Viewport ===== */
.carousel-viewport {
    position: relative;
    width: 100%;
    max-width: 2800px;
    height: 450px; /* Querformat - Halbe Höhe für mehr Landscape-Format */
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px; /* For 3D effects if needed */
}

/* ===== Track (Sliding Container) ===== */
.carousel-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    height: 100%;
    transition: none; /* Cards transition individually, not the track */
}

/* ===== Card Slots ===== */
.carousel-card {
    position: relative;
    flex-shrink: 0;
    width: 1000px;
    max-width: 1000px;
    height: 100%;
    display: flex;
    align-items: stretch; /* Volle Höhe nutzen */
    justify-content: stretch; /* Volle Breite nutzen */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity, filter;
    padding: 0;
    margin: 0;
}

/* Hide drag handle in carousel mode */
.carousel-card .drag-handle {
    display: none !important;
}

/* Make task-card inside carousel fill full width */
.carousel-card .task-card {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Previous Card (Left) */
.carousel-card--prev {
    transform: scale(0.65) translateX(20px);
    opacity: 0.5;
    filter: blur(1.5px);
    z-index: 1;
}

/* Active Card (Center) - 50% größer! */
.carousel-card--active {
    transform: scale(1.3);
    opacity: 1;
    filter: none;
    z-index: 10;
}

/* Next Card (Right) */
.carousel-card--next {
    transform: scale(0.65) translateX(-20px);
    opacity: 0.5;
    filter: blur(1.5px);
    z-index: 1;
}

/* Hidden card (out of bounds) */
.carousel-card[style*="visibility: hidden"] {
    opacity: 0;
    pointer-events: none;
}

/* Card Content Wrapper - OPTIMIZED FLEXBOX */
.carousel-card .card-content {
    width: 100%;
    height: 100%;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding: 0;
    margin: 0;
    flex: 1; /* Volle Breite nutzen */
}

/* Preview area gets ALL remaining space */
.carousel-card .task-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%; /* Volle Breite */
}

/* SVG container fills preview area */
.carousel-card .task-svg-preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0; /* KEIN Padding - volle Größe */
}

/* SVG wrapper (task-svg-preview) must also fill full size - Override shared CSS */
.carousel-card .task-svg-preview {
    width: 100%;
    height: 100%;
    max-height: none !important; /* Override shared CSS max-height: 140px */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 !important; /* Override shared CSS padding: 0.75rem */
    background: transparent !important; /* Override shared CSS background */
    border-radius: 0 !important; /* Override shared CSS border-radius */
    overflow: visible !important; /* Override shared CSS overflow: auto */
    cursor: default !important; /* Override shared CSS cursor: pointer */
    transform: none !important; /* Disable hover transform */
    transition: none !important; /* Disable transitions */
}

/* Ensure card children don't overflow */
.carousel-card--prev > *,
.carousel-card--next > * {
    pointer-events: none; /* Disable interactions on side cards */
}

.carousel-card--active > * {
    pointer-events: auto; /* Enable interactions on active card */
}

/* ===== Controls (Buttons) ===== */
.carousel-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    pointer-events: none; /* Allow clicks to pass through to cards */
    z-index: 100;
}

.carousel-btn {
    pointer-events: auto;
    width: 48px;
    height: 48px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 101;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Chevron arrows using ::before */
.carousel-btn--prev::before {
    content: '';
    width: 12px;
    height: 12px;
    border-left: 3px solid #3b82f6;
    border-bottom: 3px solid #3b82f6;
    transform: rotate(45deg);
    margin-left: 4px;
}

.carousel-btn--next::before {
    content: '';
    width: 12px;
    height: 12px;
    border-right: 3px solid #3b82f6;
    border-top: 3px solid #3b82f6;
    transform: rotate(45deg);
    margin-right: 4px;
}

.carousel-btn:hover:not(:disabled) {
    border-color: #3b82f6;
    background: #3b82f6;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.carousel-btn:hover:not(:disabled).carousel-btn--prev::before {
    border-left-color: white;
    border-bottom-color: white;
    transform: rotate(45deg) translateX(-2px);
}

.carousel-btn:hover:not(:disabled).carousel-btn--next::before {
    border-right-color: white;
    border-top-color: white;
    transform: rotate(45deg) translateX(2px);
}

.carousel-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.carousel-btn:disabled {
    border-color: rgba(156, 163, 175, 0.2);
    background: rgba(249, 250, 251, 0.8);
    cursor: not-allowed;
    opacity: 0.5;
}

.carousel-btn:disabled::before {
    border-color: #9ca3af !important;
}

/* ===== Counter ===== */
.carousel-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 50;
}

/* ===== Empty State ===== */
.carousel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #9ca3af;
    font-size: 1.25rem;
    font-weight: 500;
}

/* ===== Responsive Adjustments ===== */

/* Tablets and smaller */
@media (max-width: 1024px) {
    .carousel-viewport {
        height: 500px;
    }

    .carousel-card {
        width: 600px;
        max-width: 600px;
    }

    .carousel-track {
        gap: 1.5rem;
    }

    .carousel-card--active {
        transform: scale(1.2);
    }

    .carousel-card--prev {
        transform: scale(0.6) translateX(15px);
    }

    .carousel-card--next {
        transform: scale(0.6) translateX(-15px);
    }
}

/* Mobile (hide side cards, show only active) */
@media (max-width: 768px) {
    .carousel-viewport {
        height: 450px;
    }

    .carousel-card {
        width: 320px;
        max-width: 320px;
    }

    .carousel-track {
        gap: 1rem;
    }

    /* Hide side cards on mobile */
    .carousel-card--prev,
    .carousel-card--next {
        opacity: 0;
        pointer-events: none;
        width: 0;
        transform: scale(0);
    }

    /* Buttons smaller on mobile */
    .carousel-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .carousel-counter {
        font-size: 0.875rem;
        padding: 0.4rem 1.2rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .carousel-viewport {
        height: 400px;
    }

    .carousel-card {
        width: 280px;
        max-width: 280px;
    }

    .carousel-controls {
        padding: 0 0.5rem;
    }
}

/* ===== Smooth Animations ===== */

/* Fade-in animation on mount */
@keyframes carousel-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.carousel-container {
    animation: carousel-fade-in 0.4s ease-out;
}

/* Card entry animation */
@keyframes carousel-card-enter {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Focus Indicators (for accessibility) ===== */

.carousel-btn:focus {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

.carousel-btn:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Dark Mode Support (Optional) ===== */

@media (prefers-color-scheme: dark) {
    .carousel-counter {
        background: rgba(0, 0, 0, 0.8);
    }

    .carousel-btn {
        background: rgba(37, 99, 235, 0.9);
    }

    .carousel-btn:hover:not(:disabled) {
        background: rgba(37, 99, 235, 1);
    }

    .carousel-empty {
        color: #6b7280;
    }
}

/* ===== Print Styles (Hide carousel controls) ===== */

@media print {
    .carousel-controls,
    .carousel-counter {
        display: none !important;
    }

    .carousel-card--active {
        transform: none !important;
        opacity: 1 !important;
        filter: none !important;
    }

    .carousel-card--prev,
    .carousel-card--next {
        display: none !important;
    }
}

/* ===== Performance Optimizations ===== */

/* GPU Acceleration for smooth animations */
.carousel-card,
.carousel-btn {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* SVG Preview - MAXIMUM SIZE - Override shared styles */
.carousel-card .task-svg-preview svg {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain; /* Behält Seitenverhältnis bei */
    display: block;
}

/* Debug colors removed - layout optimized */

/* ===== NEW COMPACT CARD LAYOUT (Header/Footer in ONE line) ===== */

/* Header Compact - ONE LINE - 3-Spalten Layout */
.carousel-card .task-header-compact {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Links | Mitte | Rechts */
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    min-height: 32px;
    max-height: 32px;
    flex-shrink: 0;
    width: 100%;
    background: linear-gradient(to bottom, #fafafa, #ffffff);
}

/* Linke Spalte: Titel + AFB + Punkte */
.carousel-card .task-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-self: start;
}

.carousel-card .task-title-compact {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Rechte Spalte: Favoriten-Stern */
.carousel-card .task-header-right {
    display: flex;
    align-items: center;
    justify-self: end;
}

.carousel-card .task-points-compact {
    font-size: 0.7rem;
    font-weight: 600;
    color: #059669;
    background: #d1fae5;
    padding: 0.15rem 0.4rem;
    border-radius: 0.3rem;
    white-space: nowrap;
    line-height: 1.2;
}

.carousel-card .task-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    white-space: nowrap;
    line-height: 1.2;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* AFB Badge Farben - Ampel-System */
.carousel-card .task-badge.afb {
    font-weight: 700;
}

/* AFB I - Grün */
.carousel-card .task-badge.afb[data-afb="I"],
.carousel-card .task-badge.afb[data-afb="1"] {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

/* AFB II - Gelb */
.carousel-card .task-badge.afb[data-afb="II"],
.carousel-card .task-badge.afb[data-afb="2"] {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* AFB III - Rot */
.carousel-card .task-badge.afb[data-afb="III"],
.carousel-card .task-badge.afb[data-afb="3"] {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* AFB I-II - Grün-Gelb (Hellgrün) */
.carousel-card .task-badge.afb[data-afb="I-II"],
.carousel-card .task-badge.afb[data-afb="1-2"] {
    background: linear-gradient(135deg, #d9f99d 0%, #bef264 100%);
    color: #3f6212;
    border: 1px solid #a3e635;
}

/* AFB II-III - Orange */
.carousel-card .task-badge.afb[data-afb="II-III"],
.carousel-card .task-badge.afb[data-afb="2-3"] {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: #9a3412;
    border: 1px solid #fb923c;
}

/* Fallback für unbekannte AFB-Werte */
.carousel-card .task-badge.afb:not([data-afb]) {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    color: #374151;
    border: 1px solid #9ca3af;
}

.carousel-card .task-badge.topic {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #3730a3;
    border: 1px solid #a5b4fc;
}

.carousel-card .btn-icon-compact {
    padding: 0;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    top: -4px; /* Etwas nach oben über die Header-Linie */
}

.carousel-card .btn-favorite {
    color: rgba(209, 213, 219, 0.6); /* Durchsichtig grau wenn nicht aktiv */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

.carousel-card .btn-favorite:hover:not(.active) {
    color: rgba(209, 213, 219, 0.9); /* Etwas sichtbarer beim Hover */
    transform: scale(1.15);
}

.carousel-card .btn-favorite.active {
    color: #f59e0b; /* Goldgelb wenn aktiv */
    filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.5));
}

.carousel-card .btn-favorite.active:hover {
    transform: scale(1.2) rotate(-10deg);
    filter: drop-shadow(0 3px 8px rgba(245, 158, 11, 0.7));
}

/* Animation entfernt - zu ablenkend */

/* Footer Compact - ONE LINE - MINIMAL PADDING */
.carousel-card .task-actions-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem; /* Minimales Padding */
    margin: 0;
    border-top: 1px solid #e5e7eb;
    min-height: 28px; /* Noch kompakter */
    max-height: 28px;
    position: relative; /* For PDF modal positioning */
    flex-shrink: 0; /* Don't shrink */
    width: 100%; /* Volle Breite */
}

.carousel-card .btn-compact {
    padding: 0.2rem 0.5rem; /* Weniger Padding */
    font-size: 0.65rem; /* Kleiner */
    border-radius: 0.2rem;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.2;
}

.carousel-card .btn-compact:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.carousel-card .btn-compact.btn-add {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.carousel-card .btn-compact.btn-add:hover {
    background: #2563eb;
}

/* Usage Badges - IN DER MITTE des Headers */
.carousel-card .task-usage-badges {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    justify-self: center; /* Grid-Zentrierung */
}

.carousel-card .usage-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    border: 1px solid;
    white-space: nowrap;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .carousel-card,
    .carousel-btn,
    .carousel-container {
        transition-duration: 0.1s !important;
        animation-duration: 0.1s !important;
    }

    .carousel-card--prev,
    .carousel-card--next {
        filter: none !important;
    }
}
