/* common/style.css */

:root {
    --sidebar-w: 210px;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-light: #f3f4f6;
    --text-dark: #1e293b;
}

/* --- CRITICAL LAYOUT & VISIBILITY --- */

body {
    background-color: var(--bg-light);
    min-height: 100vh;
    /* overflow: auto;  <-- Removed to let browser handle scroll naturally */
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    padding-top: 0;
    margin: 0;
}

@media (max-width: 768px) {
    body {
        min-height: auto;
        /* Fix: Reduce blank space on mobile if content is short */
    }
}

.d-none {
    display: none !important;
}

/* Z-INDEX HIERARCHY */
#mobile-project-list {
    position: relative;
    /* Fix: was fixed bottom 0 */
    /* bottom: 0; removed */
    /* left: 0; removed */
    width: 100%;
    z-index: 1;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

/* Scroll to Top Button */
#btn-back-to-top {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: none;
    z-index: 9999;
}

#auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

#custom-processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 200000 !important;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(4px);
    flex-direction: column;
}

/* FIX: Prevent PE Tab Content Leaking on Mobile */
@media (max-width: 768px) {
    #pe-tabContent {
        display: none;
    }

    #editModal.show #pe-tabContent {
        display: block;
    }

    #editModal.show #pe-tabContent {
        display: block;
    }

    /* Ensure flex modals work */
    .modal-body.d-flex {
        min-height: 0;
    }
}

/* Universal Upload Overlay - Highest Priority */
#universal-progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 205000 !important;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Standard Modal Z-Index */
.modal {
    z-index: 100000 !important;
}

.modal-backdrop {
    z-index: 99999 !important;
}

/* FIX: Top-Level Modals (Info, Move/Copy) must be higher than EditModal */
#msgModal,
#moveCopyModal {
    z-index: 105000 !important;
}

/* --- APP STRUCTURE --- */

.app-container {
    max-width: 1600px;
    width: 95%;
    margin: 0 auto;
    min-height: 100vh;
    /* Changed from height: 100vh */
    display: flex;
    background: white;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    position: relative;
    /* z-index: 1; */
}

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 8px;
    background: #fff;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ddd;
    min-width: 0;
    /* margin-left: var(--sidebar-w); Removed for sticky sidebar */
}

.toolbar {
    padding: 15px 30px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    background: white;
    z-index: 10;
}

.workspace {
    flex: 1;
    /* overflow-y: auto; REMOVED to allow window scroll */
    padding: 30px;
    background: transparent;
}

/* --- COMPONENTS --- */

.auth-box {
    width: 100%;
    max-width: 450px;
    padding: 40px;
    text-align: center;
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.album-details-card {
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
}

#user-label {
    display: inline-block;
    font-size: 0.9rem;
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: 10px;
    color: #333;
    font-weight: bold;
}

.nav-link {
    color: #64748b;
    font-weight: 500;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 4px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: #bbd6fe;
    color: #1e40af;
}

.nav-link.active {
    background-color: #eff6ff;
    color: var(--primary);
    font-weight: 700;
}

.nav-item-hidden {
    display: none !important;
}

/* --- MOBILE SPECIFIC --- */

@media (min-width: 769px) {
    #mobile-navbar {
        display: none !important;
    }

    #mobile-project-list {
        display: none !important;
    }

    #mobile-album-view {
        display: none !important;
    }

    #desktop-settings-panel:not(.d-none) {
        display: block !important;
    }
}

/* SortableJS Fixes */
/* SortableJS Fixes */
.sortable-clone-override {
    pointer-events: none !important;
    z-index: 2147483647 !important;
    /* Max Int */
    opacity: 1 !important;
    /* Full visibility */
    transform: scale(1.05);
    /* Slight pop */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5) !important;
    cursor: grabbing !important;

    /* Layout Fixes for Body Append */
    display: block !important;
    position: fixed !important;
    /* Sortable sets this, but let's be sure */
    background: transparent !important;
    /* Let inner card handle bg */
    border: none !important;

    /* Reset Bootstrap Col behaviors */
    flex: none !important;
    max-width: 300px !important;
    /* Prevent full-width explosion */
    height: auto !important;
}

.sortable-clone-override .card {
    background: white !important;
    /* Ensure card is white */
    opacity: 1 !important;
    border: 1px solid #aaa !important;
}

.sortable-clone-override * {
    pointer-events: none !important;
}

.sortable-ghost-visible {
    opacity: 0.2;
    /* Show faint hole */
    border: 2px dashed #cbd5e1;
    background: #f1f5f9;
}

/* Ensure the dragged item (native) or active item handles transitions */
.sortable-drag-active {
    opacity: 1 !important;
    background: white;
}

/* IMPORTANT: Allow events on the grid items so they detect the drag over */
#photos-container .col {
    pointer-events: auto;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
    /* Animate the swap */
}

/* Disable transition on the drag target itself to prevent lag */
.sortable-drag,
.sortable-clone-override {
    transition: none !important;
}



.sortable-drag {
    cursor: grabbing !important;
}

@media (max-width: 768px) {
    body {
        padding-top: 0;
    }

    .app-container {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 100vh;
        box-shadow: none;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1045;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        height: auto;
    }

    .toolbar {
        display: none !important;
    }

    .workspace {
        padding: 15px;
        /* padding-bottom: 80px; REMOVED per user request */
    }

    #project-list-table {
        display: none !important;
    }

    #mobile-navbar {
        display: flex !important;
        z-index: 3000;
    }

    .album-details-card {
        display: none !important;
    }

    #mobile-project-list {
        display: block;
    }

    #desktop-settings-panel {
        display: none !important;
    }

    /* Ensure sidebar is above header */
    .sidebar {
        z-index: 3100 !important;
    }
}

/* Mode Overrides */
body.mobile-mode .app-container {
    flex-direction: column;
    height: auto;
}

body.mobile-mode .sidebar {
    /* allowed to show via toggle */
}

body.mobile-mode #mobile-navbar {
    display: flex !important;
    z-index: 3000;
}

body.mobile-mode #project-list-table {
    display: none !important;
}

body.mobile-mode #mobile-footer-nav {
    z-index: 3000 !important;
}



body.mobile-mode .toolbar {
    display: none !important;
}

body.mobile-mode #desktop-settings-panel {
    display: none !important;
}

body.mobile-mode #mobile-project-list {
    display: block;
}

body.desktop-mode .app-container {
    flex-direction: row;
    min-height: 100vh;
}

body.desktop-mode .sidebar {
    display: flex !important;
    transform: none !important;
    width: var(--sidebar-w);
}

body.desktop-mode #mobile-navbar {
    display: none !important;
}

body.desktop-mode #mobile-project-list {
    display: none !important;
}

body.desktop-mode #project-list-table {
    display: table !important;
}

body.desktop-mode #desktop-settings-panel:not(.d-none) {
    display: block !important;
}

body.desktop-mode .d-md-block {
    display: block !important;
}

body.desktop-mode .d-none.d-md-block {
    display: block !important;
}

/* --- CARDS & LISTS --- */

.mobile-album-card {
    display: block;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    text-decoration: none !important;
    color: inherit !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mobile-album-card:active {
    background: #f1f5f9;
}

.mobile-album-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
    color: #334155;
}

.mobile-album-meta {
    font-size: 0.9rem;
    color: #64748b;
}

.photo-card,
.music-card {
    display: flex;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
    align-items: flex-start;
    transition: box-shadow 0.1s;
}

.photo-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.pc-handle {
    cursor: grab;
    color: #cbd5e1;
    padding: 15px 20px;
    align-self: center;
    font-size: 1.5rem;
}

/* Thumbs */
.pc-thumb {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: 4px;
    background: #f1f5f9;
    flex-shrink: 0;
}

.pc-thumb-yt,
.pc-thumb-icon {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: 4px;
    background: #f1f5f9;
    flex-shrink: 0;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #94a3b8;
}

.pc-info {
    flex: 1;
    padding: 0 15px;
    min-width: 0;
}

.pc-title {
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pc-desc-box {
    font-size: 0.85rem;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.queue-card {
    border-left: 4px solid #cbd5e1;
}

.queue-card.q-warning {
    border-left-color: #f59e0b;
    background-color: #fffbeb;
}

.queue-card.q-critical {
    border-left-color: #ef4444;
    background-color: #fef2f2;
}

/* --- UPLOAD WIZARD STYLES --- */
#universal-progress-overlay .progress-card {
    width: 90%;
    max-width: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 30px;
    text-align: center;
}

.upload-list-container {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    margin: 20px 0;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    background: #f8fafc;
}

/* FIX: Vertical Stack for Upload Items */
.upload-item {
    display: flex;
    flex-direction: column;
    /* Stack vertically */
    align-items: flex-start;
    /* Align left */
    justify-content: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
}

/* Truncate long filenames */
.upload-item span:first-child {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: left;
}

.status-badge {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 4px;
    background: #eee;
    align-self: flex-start;
}

.status-badge.text-warning {
    background: #fff7ed;
    color: #c2410c;
}

.status-badge.text-info {
    background: #eff6ff;
    color: #1d4ed8;
}

.status-badge.text-primary {
    background: #e0e7ff;
    color: #4338ca;
}

.status-badge.text-success {
    background: #f0fdf4;
    color: #15803d;
}

.status-badge.text-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.pc-score-panel {
    width: 120px;
    border-left: 1px solid #e2e8f0;
    padding-left: 15px;
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 0.7rem;
    color: #64748b;
}

.score-total {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    text-align: center;
}

.score-bar-bg {
    background: #e2e8f0;
    height: 4px;
    width: 100%;
    border-radius: 2px;
    margin: 3px 0 6px 0;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
}

/* --- IMPORT REVIEW MASONRY --- */
.import-masonry {
    column-count: 2;
    column-gap: 15px;
}

@media (min-width: 992px) {
    .import-masonry {
        column-count: 4;
    }
}

/* Force Edit Modal Fullscreen */
#editModal .modal-dialog {
    max-width: 100%;
    margin: 0;
    height: 100%;
}

#editModal .modal-content {
    height: 100%;
    border-radius: 0;
}

.ir-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    break-inside: avoid;
}

/* --- CATEGORY VIEW STYLES --- */
.category-view-mode {
    /* Main overlay background set via JS, but handle content here */
}

.cat-section {
    width: 100%;
    margin-bottom: 30px;
    border-bottom: 1px solid #555;
    padding-bottom: 15px;
}

.cat-section h3 {
    margin-left: 10px;
    margin-bottom: 15px;
    color: #fff;
    font-size: 1.4rem;
    border-left: 4px solid var(--primary);
    padding-left: 10px;
}

/* Category View: Horizontal Columns (Kanban Style) */
.category-view-mode .masonry,
.category-view-mode #photo-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    align-items: flex-start !important;
    column-count: auto !important;
    height: calc(100vh - 100px) !important;
    padding-bottom: 20px;
    gap: 20px !important;
}

/* Reset media queries for this mode */
@media (max-width: 1200px) {
    .category-view-mode #photo-grid {
        column-count: auto !important;
    }
}

@media (max-width: 900px) {
    .category-view-mode #photo-grid {
        column-count: auto !important;
    }
}

@media (max-width: 600px) {
    .category-view-mode #photo-grid {
        column-count: auto !important;
    }
}


.category-view-mode .cat-section {
    flex: 0 0 300px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin: 0 !important;
    border-bottom: none;
}

/* Force Standard Flex Grid for Panel Board (Fix "First Column" Confusion) */
#photo-grid:not(.category-view-mode) {
    display: flex !important;
    flex-wrap: wrap !important;
    column-count: auto !important;
    gap: 15px !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    height: auto !important;
}

#photo-grid:not(.category-view-mode) .photo-item {
    flex: 0 0 auto !important;
    width: 200px !important;
    margin-bottom: 15px;
    display: inline-block !important;
    /* Override masonry inline-block? */
}

#photo-grid:not(.category-view-mode) .photo-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
}

.category-view-mode .cat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
}

.cat-row .photo-item {
    width: 150px;
    height: 150px;
    object-fit: cover;
    margin: 0;
    /* Override general margins */
    flex-grow: 0;
}

/* --- MASONRY LAYOUT --- */
.masonry-container {
    column-count: 2;
    column-gap: 15px;
}

.masonry-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    break-inside: avoid;
    transform: translateZ(0);
}

@media (min-width: 768px) {
    .masonry-container {
        column-count: 3;
    }
}

@media (min-width: 1200px) {
    .masonry-container {
        column-count: 4;
    }
}

@media (min-width: 1600px) {
    .masonry-container {
        column-count: 5;
    }
}

.cat-row .photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

b o d y    {
       o v e r s c r o l l - b e h a v i o r :    n o n e ;
       
}

   . c a r d - b o d y    {
       p o i n t e r - e v e n t s :    n o n e ;
       
}

     