/* ==================================================
   IMAGE MANAGER MODAL STYLES - Cover Page Specific
   ==================================================

   This file contains SPECIFIC styles for the Image Manager Modal
   (#combinedImageModal) used on the cover page. It inherits base modal
   styles from ../shared/modals.css and adds Image Manager specific
   functionality on top.

   IMPORTANT: This file works WITH modals.css, not instead of it!

   Features:
   - Image upload interface
   - Crop controls (movement, zoom, rotation)
   - Image gallery management
   - Responsive design

   Last Updated: [Current Date]
   ================================================== */

/* ==================================================
   1. IMAGE MANAGER Z-INDEX (Required for proper layering)
   ================================================== */

#combinedImageModal {
    z-index: 10001 !important;
}

#combinedImageModal .modal-dialog {
    z-index: 10001 !important;
    max-width: 850px;
    width: 850px;
    max-height: 90vh;
    margin: 2vh auto;
    display: flex;
    flex-direction: column;
}

#combinedImageModal .modal-content {
    z-index: 10001 !important;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

#combinedImageModal .modal-header {
    flex-shrink: 0;
}

/* ==================================================
   2. IMAGE MANAGER CONTAINER LAYOUT (Cover modal only)
   ================================================== */

/* Main container: layout/sizes defined in cover-page-modals.html inline (542px, 300px sidebar, 280px crop) */
#combinedImageModal .image-manager-container {
    display: flex;
    height: 100%;
}

#combinedImageModal .image-sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

/* Right column: crop area + controls (crop-section in HTML) */
#combinedImageModal .crop-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ==================================================
   3. UPLOAD SECTION STYLING (Cover modal only)
   ================================================== */

/* Upload section container */
#combinedImageModal .upload-section {
    text-align: center;
}

/* Upload button with drag & drop styling */
#combinedImageModal .upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px; /* Further reduced from 8px */
    padding: 10px; /* Further reduced from 12px */
    border: 2px dashed #cbd5e1;
    border-radius: 5px; /* Further reduced from 6px */
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-decoration: none;
}

#combinedImageModal .upload-btn:hover {
    border-color: #667eea;
    background: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

#combinedImageModal .upload-btn i {
    font-size: 18px; /* Further reduced from 20px */
    color: #667eea;
}

#combinedImageModal .upload-btn span {
    font-weight: 600;
    color: #374151;
    font-size: 12px; /* Further reduced from 13px */
    line-height: 1.2;
}

#combinedImageModal .upload-btn small {
    color: #6b7280;
    font-size: 10px; /* Further reduced from 11px */
    margin-top: 1px; /* Further reduced from 2px */
    line-height: 1.2;
}

/* ==================================================
   4. CROP CONTROLS SECTION (Cover modal only)
   ================================================== */

/* Controls section container */
#combinedImageModal .crop-controls-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Cover Image Manager: one row = 3 equal panels (Movement | Zoom | Rotate), then status full width below */
#combinedImageModal .crop-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    margin-bottom: 0;
    flex-shrink: 0;
}

/* First three children = the three panels; fourth = status spans full width */
#combinedImageModal .crop-controls > .control-group:nth-child(1),
#combinedImageModal .crop-controls > .control-group:nth-child(2),
#combinedImageModal .crop-controls > .control-group:nth-child(3) {
    grid-column: span 1;
}

#combinedImageModal .crop-controls > .crop-status {
    grid-column: 1 / -1;
}

#combinedImageModal .crop-controls .control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    min-width: 0;
    min-height: 82px;
    padding: 6px 6px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    box-sizing: border-box;
}

#combinedImageModal .crop-controls .control-group h6,
#combinedImageModal .crop-controls .control-title {
    font-size: 10px;
    font-weight: 600;
    color: #374151;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.2;
    width: 100%;
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
}

#combinedImageModal .crop-controls .control-group h6 i,
#combinedImageModal .crop-controls .control-title i {
    color: #667eea;
    width: 12px;
    font-size: 10px;
}

/* D-pad: 3x3 grid, fits inside panel (no overflow) */
#combinedImageModal .move-buttons {
    display: grid;
    grid-template-columns: 22px 22px 22px;
    grid-template-rows: 22px 22px 22px;
    gap: 2px;
    justify-items: center;
    align-items: center;
    width: 70px;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}
#combinedImageModal .move-buttons .move-up    { grid-column: 2; grid-row: 1; }
#combinedImageModal .move-buttons .move-left  { grid-column: 1; grid-row: 2; }
#combinedImageModal .move-buttons .move-right { grid-column: 3; grid-row: 2; }
#combinedImageModal .move-buttons .move-down  { grid-column: 2; grid-row: 3; }

#combinedImageModal .move-buttons .control-btn {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    font-size: 9px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

#combinedImageModal .zoom-controls .control-btn,
#combinedImageModal .rotate-controls .control-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
}

#combinedImageModal .crop-controls .control-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

#combinedImageModal .crop-controls .control-btn:hover:not(:disabled) {
    border-color: #667eea;
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

#combinedImageModal .crop-controls .control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#combinedImageModal .zoom-controls,
#combinedImageModal .rotate-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#combinedImageModal #combinedZoomSlider {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    accent-color: #667eea;
    height: 5px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    flex-shrink: 0;
}

#combinedImageModal #combinedZoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

#combinedImageModal #combinedZoomSlider::-webkit-slider-thumb:hover {
    background: #5a6fd8;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

#combinedImageModal #combinedZoomSlider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Status: full width row below the three panels (grid row 2) */
#combinedImageModal .crop-controls .crop-status {
    width: 100%;
    margin-top: 0;
    text-align: center;
    font-weight: 500;
    padding: 6px 10px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    margin-bottom: 0;
    flex-shrink: 0;
}

#combinedImageModal .crop-status .status-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

#combinedImageModal #cropStatusText {
    color: #374151;
    font-size: 12px;
    line-height: 1.3;
}

#combinedImageModal .loading-spinner {
    display: none;
    margin-left: 8px;
    color: #667eea;
}

/* Cover Image Manager Footer - buttons match Upload New Image style */
#combinedImageModal .image-modal-footer {
    flex-shrink: 0;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-top: 1px solid rgba(229, 231, 235, 0.6);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

#combinedImageModal .image-modal-footer .btn {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Primary (Set as Cover) - purple button: text and icon must be white */
#combinedImageModal .image-modal-footer .btn-primary {
    background: linear-gradient(45deg, #667eea, #5a67d8);
    color: #ffffff !important;
    border-color: #5a67d8;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

#combinedImageModal .image-modal-footer .btn-primary i,
#combinedImageModal .image-modal-footer .btn-primary span {
    color: #ffffff !important;
}

#combinedImageModal .image-modal-footer .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: #ffffff !important;
}

#combinedImageModal .image-modal-footer .btn-primary:hover:not(:disabled) i,
#combinedImageModal .image-modal-footer .btn-primary:hover:not(:disabled) span {
    color: #ffffff !important;
}

/* Secondary (Close) - dark text for readability */
#combinedImageModal .image-modal-footer .btn-secondary {
    background: #f8fafc;
    color: #374151;
    border-color: #e2e8f0;
}

#combinedImageModal .image-modal-footer .btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
    transform: translateY(-1px);
}

/* Outline (Reset) - strong purple text so it’s easy to see */
#combinedImageModal .image-modal-footer .btn-outline-secondary {
    background: white;
    color: #5a67d8;
    border-color: #667eea;
}

#combinedImageModal .image-modal-footer .btn-outline-secondary:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.08);
    border-color: #5a67d8;
    color: #4c51bf;
    transform: translateY(-1px);
}

#combinedImageModal .image-modal-footer .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#combinedImageModal .footer-left,
#combinedImageModal .footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#combinedImageModal .footer-left {
    flex: 1;
}

#combinedImageModal .footer-right {
    flex: 0 0 auto;
}

/* Cover Image Manager - Responsive */
@media (max-width: 768px) {
    #combinedImageModal .modal-body.image-modal-body {
        flex-direction: column;
        height: auto;
    }

    #combinedImageModal .image-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e4e8;
    }

    #combinedImageModal .crop-controls {
        grid-template-columns: 1fr;
    }

    #combinedImageModal .crop-controls > .control-group:nth-child(1),
    #combinedImageModal .crop-controls > .control-group:nth-child(2),
    #combinedImageModal .crop-controls > .control-group:nth-child(3) {
        grid-column: 1;
    }
}

/* ==================================================
   8. CROP CONTAINER (Cover modal only)
   ================================================== */

/* Crop container with image display */
#combinedImageModal .crop-container {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #f9fafb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Crop status: defined in cover-page-modals.html inline block. */

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================================================
   9. IMAGE GALLERY (Cover modal only)
   ================================================== */

/* Image gallery container */
#combinedImageModal .image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

/* Individual image thumbnail */
#combinedImageModal .image-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

#combinedImageModal .image-thumbnail:hover {
    border-color: #667eea;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

#combinedImageModal .image-thumbnail.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

#combinedImageModal .image-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==================================================
   10. RESPONSIVE DESIGN (Cover modal only)
   ================================================== */

/* Tablet responsiveness */
@media (max-width: 768px) {
    #combinedImageModal .image-manager-container {
        flex-direction: column;
        gap: 15px;
    }

    #combinedImageModal .image-sidebar {
        width: 100%;
        order: 2;
    }

    #combinedImageModal .crop-section {
        order: 1;
        min-height: 300px;
    }

    #combinedImageModal .control-group {
        padding: 12px;
    }

    #combinedImageModal .control-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    #combinedImageModal .upload-btn {
        padding: 15px;
    }

    #combinedImageModal .upload-btn i {
        font-size: 20px;
    }
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    #combinedImageModal .image-manager-container {
        gap: 10px;
    }

    #combinedImageModal .image-sidebar {
        gap: 15px;
    }

    #combinedImageModal .control-group {
        padding: 10px;
    }

    #combinedImageModal .control-btn {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    #combinedImageModal .upload-btn {
        padding: 12px;
        gap: 8px;
    }

    #combinedImageModal .upload-btn span {
        font-size: 13px;
    }

    #combinedImageModal .upload-btn small {
        font-size: 11px;
    }

    #combinedImageModal .control-title {
        font-size: 13px;
    }

    #combinedImageModal .crop-section {
        min-height: 250px;
    }
}

/* ==================================================
   11. ACCESSIBILITY & FOCUS STATES (Cover modal only)
   ================================================== */

/* Enhanced focus states for accessibility */
#combinedImageModal .control-btn:focus,
#combinedImageModal .upload-btn:focus,
#combinedImageModal .control-slider:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    #combinedImageModal .control-btn,
    #combinedImageModal .upload-btn,
    #combinedImageModal .control-group {
        border-width: 2px;
    }

    #combinedImageModal .control-btn:hover:not(:disabled) {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #combinedImageModal .control-btn,
    #combinedImageModal .upload-btn,
    #combinedImageModal .image-thumbnail,
    #combinedImageModal .loading-spinner {
        transition: none;
        animation: none;
    }

    #combinedImageModal .control-btn:hover:not(:disabled),
    #combinedImageModal .upload-btn:hover,
    #combinedImageModal .image-thumbnail:hover {
        transform: none;
    }
}

/* ==================================================
   ADDITIONAL UTILITY STYLES
   ================================================== */

/* File input - hidden by default */
#combinedUploadInput {
    display: none;
}

/* Progress container - hidden by default */
#progressContainer {
    display: none;
}

/* Progress bar - starts at 0% */
#progressBar {
    width: 0%;
}

/* Loading spinner - hidden by default */
#cropLoadingSpinner {
    display: none;
}
