/* RamblinOz Production Engine - Stylesheet */

body { font-family: Arial, sans-serif; background: #e9ecef; padding: 20px; margin: 0; }
.container { max-width: 1250px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); position: relative; }
.header { background: #A0522D; color: white; padding: 15px; text-align: center; border-radius: 4px; margin-bottom: 20px; }

/* Tabs */
.tab-nav { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid #ddd; padding-bottom: 10px; overflow-x: auto; position: sticky; top: 0; background: white; z-index: 100; padding-top: 10px; box-shadow: 0 10px 10px -10px rgba(0,0,0,0.1); }
.tab-btn { padding: 12px 24px; cursor: pointer; border: none; border-radius: 4px; background: #e9ecef; color: #333; font-weight: bold; font-size: 16px; transition: 0.3s; white-space: nowrap; }
.tab-btn.active { background: #2c3e50; color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Forms & Buttons */
button { padding: 10px 15px; cursor: pointer; border: none; border-radius: 4px; background: #A0522D; color: white; font-weight: bold; transition: 0.2s; }
button:disabled { background: #6c757d !important; cursor: not-allowed; }
input[type="text"], input[type="password"], input[type="date"], select, textarea { padding: 8px; border: 1px solid #ccc; border-radius: 3px; box-sizing: border-box; }
#status { color: #28a745; font-weight: bold; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 10px; background: #e9ecef; border-radius: 4px;}

/* Vault & Editor Layout */
.vault-layout { display: flex; gap: 20px; }
.draft-sidebar { width: 320px; background: #f8f9fa; border: 1px solid #ddd; border-radius: 5px; padding: 15px; height: 750px; display: flex; flex-direction: column; }
.draft-list-container { flex: 1; overflow-y: auto; margin-top: 10px; }
.draft-editor { flex: 1; display: flex; flex-direction: column; gap: 15px; }

/* FIXED: Changed .list-item to .sidebar-item to match the new Phase 5 UI */
.sidebar-item { background: white; padding: 10px; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 10px; cursor: pointer; border-left: 4px solid #A0522D; position: relative; display: flex; align-items: center; }
.sidebar-item:hover { background: #e9ecef; }

.editor-header-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; background: #f8f9fa; padding: 15px; border-radius: 5px; border: 1px solid #ddd; }
textarea.blog-body { height: 280px; font-size: 16px; padding: 15px; line-height: 1.5; border: 1px solid #ccc; border-radius: 4px; display: block; }

/* Sorting Office */
.controls { background: #f8f9fa; padding: 15px; border-radius: 5px; margin-bottom: 20px; display: flex; gap: 15px; align-items: center; flex-wrap: wrap; border: 1px solid #ddd; }
.holding-pen { background: #fff3f3; border: 2px dashed #dc3545; padding: 20px; border-radius: 8px; margin-bottom: 20px; min-height: 120px; }
.group-box { background: white; border: 1px solid #ccc; border-left: 5px solid #28a745; padding: 15px; border-radius: 5px; margin-bottom: 15px; }
.group-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.image-grid { display: flex; gap: 15px; flex-wrap: wrap; }
.thumb { width: 120px; background: #eee; padding: 5px; border-radius: 4px; text-align: center; position: relative; cursor: grab; }
.thumb img { width: 100%; height: 80px; object-fit: cover; border-radius: 3px; pointer-events: none; }
.thumb-info { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; color: #555; }
.remove-btn { position: absolute; top: -8px; right: -8px; background: #dc3545; color: white; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 20px; border: 2px solid white; z-index: 10; }

/* Editor Gallery Ribbon */
.editor-image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; align-content: start; height: 320px; overflow-y: scroll; padding: 15px; background: #f8f9fa; border-radius: 5px; border: 1px solid #ddd; }
.gallery-thumb-container { position: relative; text-align: center; transition: 0.2s; background: white; padding: 8px; border: 1px solid #ccc; border-radius: 5px; }
.gallery-thumb-container img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; border: 1px solid #ccc; cursor: pointer; transition: 0.2s; }
.gallery-thumb-container img:hover { border-color: #A0522D; opacity: 0.8; }
.gallery-thumb-container.inserted img { opacity: 0.4; border: 2px solid #28a745; }
.gallery-badge { display: none; position: absolute; top: -2px; left: -2px; background: #28a745; color: white; border-radius: 50%; padding: 4px 8px; font-size: 11px; font-weight: bold; z-index: 10; box-shadow: 0 2px 4px rgba(0,0,0,0.2); pointer-events: none;}
.gallery-thumb-container.inserted .gallery-badge { display: block; }
.caption-input { width: 100%; font-size: 11px; padding: 5px; margin-top: 6px; border: 1px solid #ccc; border-radius: 3px; box-sizing: border-box; background: #fff; }

/* Tags & Admin */
.tag-container { display: flex; gap: 8px; flex-wrap: wrap; background: #f8f9fa; padding: 10px; border-radius: 5px; border: 1px solid #ddd; }
.tag-pill { padding: 6px 12px; background: #e9ecef; border: 1px solid #ccc; border-radius: 15px; font-size: 12px; cursor: pointer; user-select: none; transition: 0.2s; }
.tag-pill.active { background: #A0522D; color: white; border-color: #A0522D; }
.admin-section { background: #f8f9fa; border: 1px solid #ddd; padding: 20px; border-radius: 5px; margin-bottom: 20px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.admin-list { background: white; border: 1px solid #ccc; padding: 10px; border-radius: 4px; height: 200px; overflow-y: auto; }
.admin-list-item { display: flex; justify-content: space-between; align-items: center; padding: 8px; border-bottom: 1px solid #eee; font-size: 14px; }
.linked-drafts-box { background: #fff; border: 1px solid #eee; padding: 15px; border-radius: 4px; min-height: 100px; max-height: 250px; overflow-y: auto; }
.linked-draft-item { padding: 10px; border-bottom: 1px solid #eee; font-size: 14px; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; cursor: pointer; background: #fdfdfd; border-radius: 4px; margin-bottom: 5px;}
.linked-draft-item:hover { background: #f1f3f5; border-left: 4px solid #A0522D; }

/* Map & Animations */
#mapModal { display: none; position: fixed; top: 5%; left: 5%; right: 5%; bottom: 5%; background: white; z-index: 1000; padding: 20px; border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.5); flex-direction: column; }
#mapOverlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; }
#mapContainer { flex: 1; width: 100%; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 15px; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); background-color: #dc3545; } 100% { transform: scale(1); } }
.recording { animation: pulse 1.5s infinite; background-color: #dc3545 !important; }

/* --- RAMBLINOZ PHASE 3: MOBILE OVERRIDE --- */
@media (max-width: 768px) {
    /* Stop the horizontal wiggle */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* Hide the heavy-lifting buttons on mobile */
    #btnAI, #btnPush, #btnPreview {
        display: none !important;
    }

    * {
        box-sizing: border-box !important;
    }

    .container {
        padding: 10px !important;
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    /* 1. Stack everything vertically */
    body { padding: 10px !important; }
    
    .container, .vault-layout, .editor-header-grid, .admin-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    /* 2. Sidebars and Panels take full width */
    .draft-sidebar, .draft-editor {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin-bottom: 20px !important;
    }

    /* 3. Fat-Finger Buttons */
    button {
        padding: 15px !important;
        font-size: 16px !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    /* Keep the top-row filter buttons small so they fit */
    .filter-btn {
        padding: 8px 0 !important;
        font-size: 14px !important;
    }

    /* 4. The iOS Auto-Zoom Fix */
    input[type="text"], input[type="password"], input[type="date"], select, textarea {
        font-size: 16px !important; 
        padding: 12px !important;
        width: 100% !important;
    }
    
    /* Make the main text editor taller for thumb typing */
    textarea.blog-body {
        min-height: 350px !important;
    }

    /* 5. Swipeable Image Ribbon */
    .editor-image-gallery {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        padding-bottom: 15px !important;
        height: auto !important;
    }

    .gallery-thumb-container {
        flex: 0 0 140px !important; /* Keeps thumbnails at a fixed width */
        max-width: 140px !important;
    }
    
    /* 6. Fix Map Modal for Mobile */
    #mapModal {
        width: 95% !important;
        height: 90% !important;
        top: 5% !important;
        left: 2.5% !important;
        transform: none !important;
    }

/* ==========================================
   PRODUCTION SIMULATION (Live Preview Layer)
   ========================================== */
.blog-content figure.story-image {
    margin: 30px 0;
    text-align: center;
}

.blog-content figure.story-image img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.blog-content figure.story-image figcaption {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 10px;
    font-style: italic;
}

.blog-content .post-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.blog-content .post-gallery .gallery-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    transition: 0.3s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.blog-content .post-gallery .gallery-item:hover img {
    opacity: 0.8;
}
    /* Ensure the preview iframe fills the modal window */
#previewModal {
    display: flex;
    flex-direction: column;
}

#previewContent {
    flex: 1;
    display: flex;
    padding: 0;
    overflow: hidden;
    background: #ccc; /* Gives a subtle border around the iframe */
}
/* AI Map & Summary Builder Styles */
.reorder-item.is-highlight {
    border-color: #6f42c1 !important;
    background: #f4f0fa !important;
    box-shadow: 0 0 8px rgba(111, 66, 193, 0.2);
}
/* Smaller, tighter thumbnails for the list */
.reorder-thumb-mini {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
    flex-shrink: 0;
}

/* Slightly shorter popup images so they don't dominate the map */
.map-popup-img {
    width: 100%;
    height: 60px; 
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 5px;
}
.star-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    filter: grayscale(100%);
    opacity: 0.3;
    transition: all 0.2s;
}
.reorder-item.is-highlight .star-btn {
    filter: grayscale(0%);
    opacity: 1;
}

}