/* --- Global & Theme Styles --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }

body {
    background-color: #0f172a; 
    background-image: radial-gradient(at 50% 0%, rgba(59, 130, 246, 0.1) 0, transparent 50%), 
                      radial-gradient(at 50% 100%, rgba(99, 102, 241, 0.1) 0, transparent 50%);
    background-attachment: fixed;
    color: #f1f5f9;
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Navbar (Same as Home) */
.navbar {
    background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(16px);
    padding: 10px 5%; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06); height: 70px; position: sticky; top: 0; z-index: 1000;
}
.navbar .logo { display: flex; align-items: center; gap: 12px; text-decoration: none; height: 100%; }
.navbar .logo .icon-box {
    width: 40px; height: 40px; border-radius: 8px; background: transparent;
    display: flex; align-items: center; justify-content: center; overflow: hidden; margin-top: 5px; 
}
.navbar .logo .icon-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.navbar .logo-text { font-size: 1.5rem; font-weight: 700; color: #3b82f6; display: flex; align-items: center; line-height: 1; }

/* Main Container */
.main-container { max-width: 1200px; width: 95%; margin: 60px auto; padding: 0; flex: 1; }

/* Tool Container */
.tool-container {
    position: relative; padding: 40px 30px; border-radius: 20px; overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 25%, #312e81 50%, #1e1b4b 75%, #0f172a 100%);
    background-size: 400% 400%; animation: gradientFlowNormal 15s ease infinite; 
    border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
@keyframes gradientFlowNormal { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* Header */
.tool-header {
    display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 40px; padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); position: relative; z-index: 2;
}
.tool-logo {
    width: 64px; height: 64px; border-radius: 14px; background: transparent; 
    border: 1px solid rgba(255, 255, 255, 0.2); overflow: hidden; flex-shrink: 0;
}
.tool-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tool-title { margin: 0; color: #ffffff; font-size: 1.8rem; font-weight: 600; }

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2); border-radius: 20px;
    padding: 60px 20px; text-align: center; cursor: pointer; transition: 0.3s;
    background: rgba(15, 23, 42, 0.3); position: relative; z-index: 2;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #3b82f6; background: rgba(59, 130, 246, 0.1);
}
.upload-icon-wrapper {
    font-size: 50px; color: #3b82f6; margin-bottom: 15px;
}
.upload-area h3 { font-size: 1.5rem; margin-bottom: 5px; color: #f1f5f9; }
.upload-area p { color: #94a3b8; }

/* --- Gallery & Options --- */
.gallery-container { margin-top: 30px; position: relative; z-index: 2; }

/* Toolbar */
.options-bar {
    display: flex; flex-wrap: wrap; gap: 15px; align-items: center; justify-content: space-between;
    background: rgba(15, 23, 42, 0.6); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}
.opt-group { display: flex; align-items: center; gap: 10px; }

/* Custom Inputs */
.select-style, input[type="text"] {
    background: rgba(30, 41, 59, 0.8); border: 1px solid rgba(255,255,255,0.1);
    color: white; padding: 8px 12px; border-radius: 6px; outline: none; font-size: 0.9rem;
}
.filename-input-group { display: flex; align-items: center; }
.filename-input-group input { border-radius: 6px 0 0 6px; width: 150px; }
.extension {
    background: #334155; padding: 8px 10px; border-radius: 0 6px 6px 0; border: 1px solid rgba(255,255,255,0.1); border-left: none;
    font-size: 0.9rem; color: #cbd5e1;
}

/* Gallery Grid */
.hint-text { text-align: center; color: #64748b; font-size: 0.85rem; margin-bottom: 10px; }
.gallery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px;
    max-height: 500px; overflow-y: auto; padding: 10px;
    background: rgba(15, 23, 42, 0.4); border-radius: 12px; min-height: 100px;
}

/* Image Item */
.img-item {
    position: relative; border-radius: 8px; overflow: hidden;
    background: #1e293b; border: 1px solid rgba(255,255,255,0.1);
    aspect-ratio: 3/4; cursor: grab; transition: transform 0.2s;
}
.img-item:active { cursor: grabbing; }
.img-item img { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* Item Overlay */
.img-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;
    opacity: 0; transition: 0.2s;
}
.img-item:hover .img-overlay { opacity: 1; }

.img-btn {
    width: 35px; height: 35px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: white; transition: 0.2s;
}
.btn-edit { background: #3b82f6; }
.btn-edit:hover { background: #2563eb; transform: scale(1.1); }
.btn-del { background: #ef4444; }
.btn-del:hover { background: #dc2626; transform: scale(1.1); }

/* Item Badge (Page Number) */
.page-badge {
    position: absolute; top: 5px; left: 5px; background: rgba(0,0,0,0.7);
    color: white; padding: 2px 6px; border-radius: 4px; font-size: 10px;
}

/* Action Buttons */
.action-buttons { margin-top: 30px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.btn {
    padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; gap: 8px; transition: transform 0.2s; min-width: 120px; justify-content: center;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, #2563eb, #6366f1); color: white; }
.btn-info { background: #0ea5e9; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-secondary { background: #334155; color: #cbd5e1; }


/* --- EDITOR MODAL (Advanced) --- */
.modal {
    display: none; position: fixed; z-index: 2000; left: 0; top: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
}
.editor-content {
    background: #0f172a; width: 90%; height: 90%; margin: 2% auto;
    border-radius: 12px; display: flex; flex-direction: column;
}
.modal-header {
    padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
}
.editor-body { flex: 1; overflow: hidden; background: #000; position: relative; }
.img-wrapper-editor { width: 100%; height: 100%; }
.img-wrapper-editor img { max-width: 100%; max-height: 100%; }

/* Editor Toolbar */
.editor-toolbar {
    padding: 15px; background: #1e293b; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;
}
.tool-group {
    display: flex; gap: 5px; background: rgba(0,0,0,0.3); padding: 5px; border-radius: 8px;
}
.tool-group button {
    width: 40px; height: 40px; border: none; background: transparent; color: #cbd5e1;
    border-radius: 6px; cursor: pointer; font-size: 16px; transition: 0.2s;
}
.tool-group button:hover { background: rgba(255,255,255,0.1); color: white; }
.tool-group button:active { transform: scale(0.95); }

/* Loading Overlay */
.loading-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 3000; flex-direction: column;
    justify-content: center; align-items: center; color: white;
}
.spinner {
    width: 50px; height: 50px; border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid #3b82f6; border-radius: 50%; animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Footer */
footer {
    text-align: center; padding: 25px; color: #94a3b8; background-color: #0b0f19;
    margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobile Fix */
@media (max-width: 768px) {
    .options-bar { flex-direction: column; align-items: stretch; }
    .editor-toolbar { gap: 10px; }
    .tool-group button { width: 35px; height: 35px; font-size: 14px; }
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}