/* ========================================
   Photo Collage - Premium Styling Stylesheet
   ======================================== */

.collage-body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Outer layout wrapper */
.collage-main-container {
    display: flex;
    flex: 1;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

@media (max-width: 1024px) {
    .collage-main-container {
        flex-direction: column;
    }
}

/* Sidebar Styling with Glassmorphism */
.collage-sidebar {
    width: 380px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

@media (max-width: 1024px) {
    .collage-sidebar {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

.sidebar-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

body.dark-theme .sidebar-section {
    background: rgba(255, 255, 255, 0.01);
}

.sidebar-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.sidebar-section h3 i {
    color: var(--accent);
}

/* Disabled styling for Image Adjust bar */
.disabled-section {
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
    position: relative;
}

.disabled-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
}

/* Inputs & Labels */
.input-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.input-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Sliders */
.input-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    margin: 8px 0;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.input-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    align-self: flex-end;
    margin-top: -4px;
}

/* Colors Input */
.input-group input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

.input-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.input-group input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

/* Switch & Toggles */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    box-shadow: var(--shadow-sm);
}

input:checked + .slider {
    background-color: var(--accent);
    border-color: transparent;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Edit Panel Details */
.edit-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.edit-bar-header h3 {
    margin-bottom: 0;
}

.badge {
    background: var(--accent-glow);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
}

.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.edit-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.edit-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-light);
}

.edit-btn.danger-btn {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.edit-btn.danger-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

/* Export Buttons */
.export-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    border: none;
    color: white;
}

.export-btn:last-child {
    margin-bottom: 0;
}

.png-btn {
    background: var(--grad-primary);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.png-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.pdf-btn {
    background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.2);
}

.pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(234, 88, 12, 0.35);
}

/* Preview Content Grid Area */
.collage-preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: var(--bg-tertiary);
    overflow: auto;
    align-items: center;
    position: relative;
    max-height: calc(100vh - 70px);
}

.canvas-instructions {
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    width: fit-content;
}

.canvas-instructions i {
    color: var(--accent);
}

.canvas-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.02);
    min-height: 800px;
    width: 100%;
}

/* ========================================================
   Live Canvas Styles (Dynamic Dimensions in JS based on sizes)
   ======================================================== */
.collage-canvas {
    background: #ffffff;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    display: grid;
    transition: width 0.4s ease, height 0.4s ease;
}

/* Show dashed lines behind image placements when grid mode active */
.collage-canvas.show-grid-lines {
    background-image: 
        radial-gradient(var(--border-color) 1px, transparent 1px),
        radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Grid Slots styling */
.collage-slot {
    position: relative;
    overflow: hidden;
    background: #f8fafc;
    border: 1px dashed rgba(99, 102, 241, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

body.dark-theme .collage-slot {
    background: #1e293b;
}

.collage-slot:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* Slot selection focus */
.collage-slot.selected-slot {
    border: 3px solid var(--accent) !important;
    box-shadow: inset 0 0 0 2px white, 0 0 15px var(--accent-glow);
    z-index: 5;
}

/* Slot UI labels / upload indicators */
.slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    text-align: center;
    padding: 10px;
}

.slot-placeholder i {
    font-size: 24px;
    color: var(--text-muted);
    opacity: 0.7;
    transition: var(--transition);
}

.collage-slot:hover .slot-placeholder i {
    color: var(--accent);
    transform: scale(1.15);
}

/* Dynamically loaded images within slots */
.slot-image-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    pointer-events: none;
}

.slot-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center center;
    transition: filter 0.15s ease;
}

/* Grid Templates */
/* 2 Images horizontal */
.grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

/* 4 Images square grid */
.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* 6 Images portrait stack */
.grid-6 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

/* 6 Images horizontal grid */
.grid-6-horiz {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* Trending Layout 1 (Hero Left, Two smaller stacked on Right) */
.grid-trending {
    grid-template-columns: 1.8fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.grid-trending .collage-slot:nth-child(1) {
    grid-row: span 2;
}

/* Trending Layout 2 (1 Top main, 4 smaller stacked below) */
.grid-trending-2 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1.5fr 1fr;
}

.grid-trending-2 .collage-slot:nth-child(1) {
    grid-column: span 4;
}

/* Delete Button on cell hover */
.slot-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.collage-slot:hover .slot-delete-btn {
    opacity: 1;
}

.slot-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
}

/* ============================================================
   SMART BULK SETUP MODAL — Premium Styling
   ============================================================ */

/* Overlay backdrop */
.smart-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayFadeIn 0.25s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Modal Box */
.smart-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 40px 80px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal Header */
.smart-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.smart-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--grad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 6px 20px var(--accent-glow);
}

.smart-modal-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.smart-modal-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.smart-modal-close {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.smart-modal-close:hover {
    background: rgba(239,68,68,0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* Image Counter Banner */
.smart-image-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.08) 100%);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 14px;
    padding: 14px 20px;
    margin-bottom: 24px;
}

.counter-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
}

.counter-badge i {
    font-size: 20px;
}

.counter-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Section Block */
.smart-section {
    margin-bottom: 24px;
}

.smart-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 14px;
}

.smart-section-title i {
    color: var(--accent);
    font-size: 14px;
}

/* Paper Size Cards Grid */
.paper-size-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

@media (max-width: 600px) {
    .paper-size-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.paper-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 8px;
    border-radius: 14px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    position: relative;
}

.paper-btn:hover {
    border-color: var(--accent-light);
    background: rgba(99,102,241,0.05);
    transform: translateY(-2px);
}

.paper-btn.active {
    border-color: var(--accent);
    background: rgba(99,102,241,0.08);
    color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* Paper icon shapes */
.paper-icon {
    background: currentColor;
    opacity: 0.3;
    border-radius: 3px;
    transition: var(--transition);
}

.paper-btn.active .paper-icon {
    opacity: 0.6;
}

.paper-portrait {
    width: 18px;
    height: 24px;
}

.paper-landscape {
    width: 24px;
    height: 18px;
}

.paper-square {
    width: 20px;
    height: 20px;
}

.paper-label {
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.paper-sub {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.7;
    line-height: 1;
}

/* Per Page Options Grid */
.per-page-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.per-page-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 80px;
    padding: 14px 10px;
    border-radius: 14px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    position: relative;
}

.per-page-btn:hover {
    border-color: var(--accent-light);
    background: rgba(99,102,241,0.05);
    transform: translateY(-2px);
}

.per-page-btn.active {
    border-color: var(--accent);
    background: rgba(99,102,241,0.08);
    color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* Mini Grid Preview inside per-page button */
.mini-grid-preview {
    display: grid;
    gap: 2px;
    width: 36px;
    height: 28px;
}

.mini-grid-preview .mini-cell {
    background: currentColor;
    opacity: 0.35;
    border-radius: 2px;
}

.per-page-number {
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
}

.per-page-label {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.7;
    line-height: 1;
    text-align: center;
}

/* Page Summary Bar */
.smart-page-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 20px;
    margin-bottom: 24px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    justify-content: center;
}

.summary-item i {
    color: var(--accent);
    font-size: 15px;
}

.summary-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
}

/* Action Buttons */
.smart-modal-actions {
    display: flex;
    gap: 12px;
}

.smart-btn-cancel {
    flex: 1;
    padding: 14px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.smart-btn-cancel:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.smart-btn-apply {
    flex: 2;
    padding: 14px;
    font-size: 14px;
    font-weight: 800;
    border-radius: 14px;
    border: none;
    background: var(--grad-primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px var(--accent-glow);
}

.smart-btn-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(99,102,241,0.35);
}

.smart-btn-apply:active {
    transform: translateY(0);
}

/* ============================================================
   PAGE NAVIGATION BAR (Multi-Page Mode)
   ============================================================ */

.page-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
    min-width: 340px;
}

.page-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 50px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.page-nav-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.page-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-nav-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.page-nav-center #pageNavText {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-dots {
    display: flex;
    align-items: center;
    gap: 5px;
}

.page-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.page-dot.active {
    background: var(--accent);
    transform: scale(1.3);
    box-shadow: 0 0 6px var(--accent-glow);
}

.page-dot:hover {
    background: var(--accent-light);
}

/* ============================================================
   PAPER GROUP TABS (inside Smart Modal)
   ============================================================ */

.paper-group-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.paper-tab {
    padding: 7px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.paper-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.paper-tab:hover:not(.active) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Paper group grid inside modal */
.paper-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: 4px;
}

/* Override paper-size-grid for dynamic content container */
#paperSizeGrid {
    display: block !important;
    grid-template-columns: unset !important;
}

/* ============================================================
   EXPORT ALL PAGES BUTTON
   ============================================================ */

.all-pages-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2) !important;
}

.all-pages-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35) !important;
}
