/**
 * Motion Library - Component Styles
 * Cards, Modals, Video Player, Badges, Toast & Preview Manager
 */

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: #ffffff;
    box-shadow: 0 0 15px var(--accent-purple-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #9d6fff, #6d28d9);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border-color: var(--border-medium);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: #1e2233;
    border-color: var(--border-highlight);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}
.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* Software Badges */
.badge-software {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-software.sw-ae { background: var(--sw-ae-bg); color: var(--sw-ae); border: 1px solid rgba(157, 78, 221, 0.3); }
.badge-software.sw-pr { background: var(--sw-pr-bg); color: var(--sw-pr); border: 1px solid rgba(189, 83, 237, 0.3); }
.badge-software.sw-mogrt { background: var(--sw-mogrt-bg); color: var(--sw-mogrt); border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-software.sw-ps { background: var(--sw-ps-bg); color: var(--sw-ps); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-software.sw-ai { background: var(--sw-ai-bg); color: var(--sw-ai); border: 1px solid rgba(249, 115, 22, 0.3); }
.badge-software.sw-video { background: var(--sw-video-bg); color: var(--sw-video); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-software.sw-other { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   PROJECT CARDS & GALLERY
   ========================================================================== */

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

.projects-grid.dense {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

/* Card Structure */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-highlight);
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.8), 0 0 20px -5px var(--accent-purple-glow);
}

/* Media Thumbnail Container */
.card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #0b0d14;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.project-card:hover .card-thumb-img {
    transform: scale(1.04);
}

/* Video Hover Player in Card */
.card-hover-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.project-card:hover .card-hover-video.is-active {
    opacity: 1;
}

/* Transparent Background Checkerboard */
.checkerboard-bg {
    background-image: 
        linear-gradient(45deg, #181b24 25%, transparent 25%), 
        linear-gradient(-45deg, #181b24 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #181b24 75%), 
        linear-gradient(-45deg, transparent 75%, #181b24 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* Fallback / Unsupported Card Placeholder */
.card-no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #181a28, #0e1017);
    color: var(--text-muted);
    text-align: center;
    padding: 16px;
}

.no-preview-icon {
    width: 36px;
    height: 36px;
    opacity: 0.4;
    color: var(--accent-purple);
}

.no-preview-text {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 180px;
    line-height: 1.3;
}

/* Card Floating Badges */
.card-badges-top {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.card-badges-top > * {
    pointer-events: auto;
}

.btn-card-fav {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(10, 12, 18, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-card-fav:hover, .btn-card-fav.active {
    color: var(--accent-rose);
    border-color: rgba(244, 63, 94, 0.4);
    transform: scale(1.1);
}

.btn-card-fav.active {
    background: rgba(244, 63, 94, 0.2);
}

.card-play-pill {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(10, 12, 18, 0.8);
    backdrop-filter: blur(6px);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Card Body Content */
.card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.card-meta-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

.card-meta-category {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.card-size {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* List View Variant */
.projects-grid.list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.projects-grid.list .project-card {
    flex-direction: row;
    height: 72px;
    align-items: center;
    padding: 0 16px;
}

.projects-grid.list .card-media {
    width: 80px;
    height: 50px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.projects-grid.list .card-body {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    width: 100%;
}

.projects-grid.list .card-meta-line {
    border-top: none;
    padding-top: 0;
    gap: 16px;
}

/* ==========================================================================
   MODALS & THEATER PREVIEW
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
    padding: 24px;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-modal);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-elevated);
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(10px);
    transition: transform var(--transition-smooth);
}

.modal-backdrop.open .modal-box {
    transform: scale(1) translateY(0);
}

/* Project Details Modal Layout */
.project-modal-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: 620px;
}

.modal-left-media {
    background: #06070a;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px solid var(--border-subtle);
    overflow: hidden;
}

.modal-media-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.modal-media-viewport video,
.modal-media-viewport img,
.modal-media-viewport iframe {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-media-viewport iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.modal-variation-tabs {
    padding: 10px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
}

.var-tab {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.var-tab.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-purple);
    color: #ffffff;
}

/* Modal Right Sidebar (Inspector) */
.modal-right-info {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    overflow-y: auto;
    padding: 24px;
}

.modal-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-project-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 6px;
    word-break: break-word;
}

.modal-filename {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
}

.modal-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 18px 0;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.meta-field-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.meta-field-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-actions-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding-top: 20px;
}

/* ==========================================================================
   PREVIEW MANAGER SECTION
   ========================================================================== */

.pm-header-stats {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.pm-progress-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
}

.coverage-gauge {
    position: relative;
    width: 76px;
    height: 76px;
}

.coverage-gauge svg {
    transform: rotate(-90deg);
}

.coverage-pct-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.pm-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 20px;
}

.pm-tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.pm-tab-btn:hover {
    color: var(--text-primary);
}

.pm-tab-btn.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
}

/* Candidate Suggestion Pill in Preview Manager */
.candidate-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.candidate-pill:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.15);
}

/* ==========================================================================
   SCANNER MODAL WITH REAL-TIME PROGRESS & LOG STREAM
   ========================================================================== */

.scan-progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
    position: relative;
}

.scan-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    box-shadow: 0 0 10px var(--accent-purple-glow);
    transition: width 0.3s ease;
}

.scan-log-box {
    background: #08090e;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    height: 160px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-elevated);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.toast-success { border-left: 3px solid var(--accent-emerald); }
.toast.toast-error { border-left: 3px solid var(--accent-rose); }
.toast.toast-info { border-left: 3px solid var(--accent-cyan); }
