/* Image Upload Styling for Vision Models (Gemma 3 12B) - Modern Modal Design */

/* ========================================
   UPLOAD BUTTON
   ======================================== */

/* Input Text Row - ensure proper flex layout with button */
.input-text-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.input-text-row .input-wrapper {
    flex: 1; /* Take remaining space */
}

/* Upload Button (+) */
.image-upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.image-upload-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 180, 216, 0.3);
}

.image-upload-button:active {
    transform: scale(0.95);
}

.image-upload-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

.image-upload-button svg {
    width: 20px;
    height: 20px;
}

/* Button Loading State */
.image-upload-button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.image-upload-button.loading svg {
    animation: rotate-pulse 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

@keyframes rotate-pulse {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ========================================
   COMPACT IMAGE PILL (Right Side)
   ======================================== */

.image-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(0, 180, 216, 0.15);
    border: 1px solid rgba(0, 180, 216, 0.3);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #00b4d8;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto; /* Push to right */
    margin-right: 8px;
    user-select: none;
}

.image-pill:hover {
    background: rgba(0, 180, 216, 0.25);
    transform: scale(1.05);
    border-color: rgba(0, 180, 216, 0.4);
}

.image-pill:active {
    transform: scale(0.95);
}

.image-pill.hidden {
    display: none;
}

.image-pill .pill-icon {
    font-size: 16px;
    line-height: 1;
}

.image-pill .pill-count {
    font-weight: 600;
}

/* Pill Bounce Animation */
.image-pill.pill-bounce {
    animation: pill-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pill-bounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    70% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ========================================
   CENTER SCREEN UPLOAD MODAL
   ======================================== */

/* Modal Overlay (Backdrop) */
.image-upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.image-upload-modal.visible {
    opacity: 1;
    pointer-events: all;
}

/* Modal Card */
.upload-modal-card {
    background: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.image-upload-modal.visible .upload-modal-card {
    transform: scale(1);
}

/* Circular Progress Container */
.modal-progress-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.circular-progress {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

/* Progress Ring Background */
.progress-ring-bg {
    fill: none;
    stroke: rgba(0, 180, 216, 0.1);
    stroke-width: 8;
}

/* Progress Ring (Animated) */
.progress-ring {
    fill: none;
    stroke: #00b4d8;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 282.6; /* 2 * PI * 45 */
    stroke-dashoffset: 282.6; /* Start at 0% */
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0.0, 0.2, 1),
                stroke 0.3s ease;
}

.progress-ring.success {
    stroke: #10b981; /* Green */
}

/* Progress Percentage (Center) */
.progress-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
    color: #00b4d8;
    transition: color 0.3s ease;
}

.progress-ring.success + .progress-percentage {
    color: #10b981;
}

/* Status Message */
.modal-status {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.modal-status.success {
    color: #10b981;
}

/* Preview Thumbnail */
.modal-preview {
    margin: 20px 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Cancel Button */
.modal-cancel-btn {
    padding: 10px 24px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-cancel-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

/* ========================================
   IMAGE MANAGER OVERLAY (Click Pill)
   ======================================== */

.image-manager-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.image-manager-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* Manager Card */
.image-manager-card {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.image-manager-overlay.visible .image-manager-card {
    transform: scale(1);
}

/* Manager Header */
.manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.manager-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.manager-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #666;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manager-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Manager Grid */
.manager-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.manager-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.manager-image-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.manager-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.manager-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
}

.manager-image-item:hover .manager-remove-btn {
    opacity: 1;
}

.manager-remove-btn:hover {
    transform: scale(1.1);
    background: rgba(239, 68, 68, 1);
}

.manager-image-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 10px;
    display: flex;
    justify-content: space-around;
    gap: 4px;
}

.manager-image-info span {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.manager-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* Done Button */
.manager-done-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.manager-done-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
}

.manager-done-btn:active {
    transform: translateY(0);
}

/* ========================================
   MESSAGE IMAGE THUMBNAILS (Chat History)
   ======================================== */

.message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 4px;
}

.message-image-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(0, 180, 216, 0.2);
}

.message-image-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
    border-color: rgba(0, 180, 216, 0.4);
}

.message-image-thumbnail:active {
    transform: scale(0.98);
}

/* ========================================
   DRAG AND DROP OVERLAY
   ======================================== */

#drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95), rgba(118, 75, 162, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(8px);
}

#drop-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.drop-overlay-content {
    text-align: center;
    color: white;
    animation: bounce 1s ease-in-out infinite;
}

.drop-overlay-content svg {
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.drop-overlay-content p {
    font-size: 28px;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.drop-overlay-content .drop-hint {
    font-size: 16px;
    font-weight: normal;
    margin-top: 8px;
    opacity: 0.9;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .upload-modal-card,
    .image-manager-card {
        background: #1a1a1a;
        color: white;
    }

    .manager-header h3 {
        color: white;
    }

    .modal-status {
        color: #e0e0e0;
    }

    .progress-ring-bg {
        stroke: rgba(102, 126, 234, 0.2);
    }

    .progress-percentage {
        color: #a5b4fc;
    }

    .manager-close-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #e0e0e0;
    }

    .manager-close-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        color: white;
    }

    .modal-cancel-btn {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }

    .modal-cancel-btn:hover {
        border-color: #667eea;
        color: #a5b4fc;
        background: rgba(102, 126, 234, 0.1);
    }

    .manager-image-item {
        background: #2a2a2a;
    }

    .image-pill {
        background: rgba(102, 126, 234, 0.2);
        border-color: rgba(102, 126, 234, 0.4);
        color: #a5b4fc;
    }

    .image-pill:hover {
        background: rgba(102, 126, 234, 0.3);
    }

    .message-image-thumbnail {
        border-color: rgba(102, 126, 234, 0.3);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .message-image-thumbnail:hover {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        border-color: rgba(102, 126, 234, 0.5);
    }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .upload-modal-card,
    .image-manager-card {
        padding: 24px;
        width: 95%;
    }

    .modal-progress-container {
        width: 100px;
        height: 100px;
    }

    .circular-progress {
        width: 100px;
        height: 100px;
    }

    .progress-percentage {
        font-size: 24px;
    }

    .modal-status {
        font-size: 14px;
    }

    .manager-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }

    .image-pill {
        margin-right: 4px;
        padding: 6px 10px;
        font-size: 12px;
    }

    .image-pill .pill-icon {
        font-size: 14px;
    }

    .message-image-thumbnail {
        width: 60px;
        height: 60px;
    }

    .image-upload-button {
        width: 32px;
        height: 32px;
    }

    .image-upload-button svg {
        width: 18px;
        height: 18px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .message-image-thumbnail {
        width: 70px;
        height: 70px;
    }

    .manager-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* ========================================
   ACCESSIBILITY - REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .image-upload-button.loading svg {
        animation: none;
        opacity: 0.5;
    }

    .image-pill.pill-bounce {
        animation: none;
    }

    .drop-overlay-content {
        animation: none;
    }

    .modal-preview img {
        animation: none;
    }

    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
