/* =========================================
   FRESH CSS ARCHITECTURE - PRO UI
========================================= */

/* Default Variables (Light Mode to sync with components.js) */
:root {
    --bg-dark: #f1f5f9;
    --bg-panel: #ffffff;
    --border-color: #cbd5e1;
    --primary: #3b82f6;
    --danger: #ef4444;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --workspace-bg: #e2e8f0;
}

/* Dark Mode Overrides (Controlled by components.js) */
body.dark-mode {
    --bg-dark: #0b1120;
    --bg-panel: #1e293b;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --workspace-bg: #060b14;
}

body.app-body {
    margin: 0; padding: 0; 
    overflow-x: hidden; /* Main Scroll ON */
    background-color: var(--bg-dark); 
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Global App Shell (Adjusted for global navbar) */
.app-container {
    display: flex; flex-direction: column;
    height: calc(100vh - 64px); 
    margin-top: 64px; /* Space for components.js navbar */
    background: var(--bg-dark);
}

/* --- Top Toolbar --- */
.app-toolbar {
    height: 60px; background: var(--bg-panel); border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; padding: 0 20px; flex-shrink: 0;
    overflow-x: auto;
}
.app-toolbar::-webkit-scrollbar { height: 0px; }

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 15px; }
.app-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap;}
.pro-badge { background: var(--primary); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: 800; }

.btn-icon { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); width: 34px; height: 34px; border-radius: 6px; cursor: pointer; transition: 0.2s; display: grid; place-items: center;}
.btn-icon:hover { background: var(--border-color); }

.setting-group { display: flex; align-items: center; gap: 5px; background: var(--bg-dark); padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border-color); white-space: nowrap;}
.setting-group label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.setting-group select, .setting-group input { background: transparent; border: none; color: var(--text-main); font-weight: 600; font-size: 13px; outline: none; }
.setting-group select option { background: var(--bg-panel); color: var(--text-main); }
.setting-group input[type="number"] { width: 40px; text-align: center; color: var(--primary); }
.v-divider { width: 1px; height: 24px; background: var(--border-color); margin: 0 5px; }

.checkbox-group { background: transparent; border: none; cursor: pointer; }
.checkbox-group label { cursor: pointer; color: var(--text-main); font-size: 13px; text-transform: none; }
.checkbox-group input { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer;}

/* --- Middle Layout --- */
.app-body-row { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.app-sidebar { width: 320px; background: var(--bg-panel); border-right: 1px solid var(--border-color); padding: 15px; display: flex; flex-direction: column; flex-shrink: 0; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #3b82f6); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; transition: 0.2s; }
.btn-primary:hover { filter: brightness(1.1); }
.w-full { width: 100%; }
.hint-text { font-size: 12px; color: var(--text-muted); text-align: center; margin: 10px 0 15px 0; }

.custom-dims { background: var(--bg-dark); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 15px; }
.custom-dims label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 5px; font-weight: bold;}
.dim-inputs { display: flex; gap: 10px; }
.dim-inputs input { flex: 1; background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-main); padding: 6px; border-radius: 4px; outline: none; }

/* File List */
.file-list-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; max-height: 500px; }
.panel-header { padding: 10px 12px; background: var(--bg-panel); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.badge-count { background: var(--primary); color: white; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.panel-body { flex: 1; padding: 10px; overflow-y: auto; }

/* Thumbnail Items */
.thumb-item { display: flex; align-items: center; gap: 10px; background: var(--bg-panel); border: 1px solid var(--border-color); padding: 8px; border-radius: 6px; margin-bottom: 8px; cursor: grab; transition: 0.2s; }
.thumb-item:active { cursor: grabbing; }
.thumb-item.dragging { opacity: 0.4; border: 1px dashed var(--primary); }
.thumb-item.drag-over { border-top: 3px solid var(--primary); transform: translateY(2px); }
.thumb-img { width: 45px; height: 45px; object-fit: cover; border-radius: 4px; background: #000; }
.thumb-info { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.thumb-actions { display: flex; gap: 5px; }
.act-btn { background: transparent; border: none; cursor: pointer; color: var(--text-muted); font-size: 15px; transition: 0.2s; }
.act-btn.rotate:hover { color: #f59e0b; }
.act-btn.delete:hover { color: var(--danger); }

/* --- Workspace --- */
.app-workspace { flex: 1; background: var(--workspace-bg); position: relative; display: flex; flex-direction: column; padding: 40px 20px; align-items: center; overflow-y: auto; }
.empty-state { text-align: center; color: var(--border-color); margin: auto; }
.empty-state h3 { color: var(--text-muted); margin: 15px 0 5px 0; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

.preview-feed { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 40px; padding-bottom: 40px;}
.preview-card { background: var(--bg-panel); border: 2px solid var(--border-color); border-radius: 12px; padding: 15px; box-shadow: 0 15px 35px rgba(0,0,0,0.1); position: relative; max-width: 800px; width: 100%; }
body.dark-mode .preview-card { box-shadow: 0 15px 35px rgba(0,0,0,0.3); }
.preview-card canvas { display: block; width: 100%; height: auto; background: white; border-radius: 4px; border: 1px solid var(--border-color); }
.card-label { text-align: center; margin-top: 12px; font-size: 14px; font-weight: bold; color: var(--text-muted); letter-spacing: 1px; }

.btn-delete-page { position: absolute; top: -15px; right: -15px; background: var(--danger); color: white; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4); display: grid; place-items: center; transition: 0.2s; z-index: 10;}
.btn-delete-page:hover { transform: scale(1.15); background: #dc2626; }

/* --- Bottom Action Bar --- */
.app-bottom-bar { height: 60px; background: var(--bg-panel); border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; flex-shrink: 0; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-success { background: #10b981; color: white; border: none; padding: 10px 24px; border-radius: 6px; font-weight: 700; font-size: 15px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: 0.2s; }
.btn-success:hover { background: #059669; }
.btn-success:disabled { background: var(--border-color); color: var(--text-muted); cursor: not-allowed; }

/* --- Loader --- */
.loader-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 18px; }
.spinner { border: 4px solid #334155; border-top: 4px solid #3b82f6; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.progress-bar-bg { width: 300px; height: 8px; background: #334155; border-radius: 10px; margin-top: 20px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: #3b82f6; transition: 0.2s; }

/* Custom Scrollbars */
.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* Mobile View Adjustments */
@media (max-width: 768px) {
    .app-body-row { flex-direction: column; }
    .app-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); max-height: max-content; }
    .file-list-panel { max-height: 250px; }
}