/* Core Variables */
:root {
    --babyt-primary: #21bfd1;
    --babyt-danger: #ff5252;
    --babyt-warning: #ffc107;
    --babyt-border: #ddd;
    --babyt-text: #333;
    --babyt-text-light: #666;
    --babyt-bg: #f9f9f9;
    --babyt-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --babyt-radius: 6px;
    --babyt-transition: all 0.3s ease;
}

.babyt-product-media-manager {
    padding: 15px; /* Slightly reduce padding for mobile */
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.babyt-media-upload-section {
    margin-bottom: 25px;
}

.babyt-upload-dropzone {
    border: 2px dashed #ccc; /* Slightly thinner border */
    border-radius: 8px;
    padding: 30px 15px; /* Adjust padding */
    text-align: center;
    background: #f9f9f9;
    cursor: pointer;
    transition: all 0.3s ease;
}

.babyt-upload-dropzone:hover {
    border-color: #21bfd1;
    background: #f5f5f5;
}

.babyt-upload-dropzone i {
    font-size: 36px; /* Smaller icon */
    color: #21bfd1;
    margin-bottom: 10px;
}

.babyt-upload-dropzone h3 {
    margin: 0 0 8px;
    color: #333;
    font-size: 1.1em; /* Adjust font size */
}

.babyt-upload-dropzone p {
    margin: 0;
    color: #666;
    font-size: 0.9em; /* Adjust font size */
}

.babyt-upload-progress {
    margin-top: 15px;
}

.progress-bar {
    height: 18px; /* Slightly smaller bar */
    background: #f0f0f0;
    border-radius: 9px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #21bfd1;
    width: 0;
    transition: width 0.3s ease;
}

.progress-text {
    display: block;
    text-align: center;
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

.babyt-media-gallery h3 {
    margin-bottom: 15px;
}

.babyt-media-grid {
    display: grid;
    /* Responsive grid with specific breakpoints */
    grid-template-columns: repeat(2, 1fr); /* Default 2 columns for mobile */
    gap: 15px; /* Adjust gap */
    margin-top: 15px;
}

/* Mobile: 2 columns */
@media screen and (max-width: 767px) {
    .babyt-media-grid {
        grid-template-columns: repeat(2, 1fr); /* Changed from 3 to 2 */
    }
}

/* Tablet: Also 3 columns (Changed from 3) */
@media screen and (min-width: 768px) {
    .babyt-media-grid {
        grid-template-columns: repeat(3, 1fr); /* Changed from 3 to 2 */
    }
}

/* Desktop: 4 columns */
@media screen and (min-width: 1024px) {
    .babyt-media-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.babyt-media-item {
    border: 1px solid #ddd;
    border-radius: 6px; /* Slightly smaller radius */
    overflow: hidden;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08); /* Softer shadow */
    display: flex;
    flex-direction: column; /* Stack preview and actions */
}

.babyt-media-preview {
    position: relative;
    padding-top: 100%; /* 1:1 Aspect ratio */
    background-color: #eee;
    overflow: hidden; /* Ensure image fits */
    cursor: pointer; /* Indicate clickable */
}

.babyt-media-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    will-change: transform; /* Optimize animations */
    backface-visibility: hidden; /* Prevent flickering */
}

.babyt-media-video-preview .video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px; /* Smaller icon */
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
    text-shadow: 0 0 8px rgba(0,0,0,0.6);
}

.babyt-media-actions {
    padding: 8px; /* Adjust padding */
    display: flex;
    justify-content: space-between; /* Keep space between */
    align-items: center;
    background: #f9f9f9;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 5px; /* Add gap between wrapped items */
}

.babyt-media-actions button,
.babyt-media-actions .babyt-featured-badge {
    padding: 4px 8px; /* Adjust padding */
    border-radius: 4px;
    font-size: 0.85em; /* Smaller text */
    cursor: pointer;
    border: none;
    text-align: center;
    flex-grow: 1; /* Allow buttons to grow */
    min-width: 60px; /* Minimum width before wrapping */
}
.babyt-media-actions button i,
.babyt-media-actions .babyt-featured-badge i {
    margin-right: 4px;
}

.babyt-media-delete {
    background: #ff5252;
    color: white;
    order: 2; /* Move delete to the right visually if space allows */
    flex-grow: 0; /* Don't let delete grow as much */
}

.babyt-set-featured {
    background: #21bfd1;
    color: white;
    order: 1;
}
.babyt-set-featured .button-text {
    display: inline; /* Show text by default */
}


.babyt-featured-badge {
    background: #ffc107;
    color: #333;
    order: 1;
    cursor: default;
    flex-grow: 1; /* Allow badge to take space */
}

button:hover {
    opacity: 0.85;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.babyt-no-media {
    grid-column: 1 / -1; /* Span full width if grid is empty */
    text-align: center;
    color: #666;
    padding: 20px;
}

/* Media Modal Styles */
.babyt-media-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(2px);
}

.babyt-modal-content {
    position: relative;
    margin: auto;
    padding: 0;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    top: 50%;
    transform: translateY(-50%);
}

.babyt-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.babyt-modal-body {
    padding: 0;
    text-align: center;
    max-height: 90vh;
    overflow: hidden;
}

.babyt-modal-body img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.babyt-modal-body video {
    max-width: 100%;
    max-height: 90vh;
    background: black;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    /* This media query now only adjusts actions padding/font size,
       as the grid columns are handled by the default and min-width: 768px rules */
    .babyt-media-actions {
        padding: 6px;
    }
    .babyt-media-actions button,
    .babyt-media-actions .babyt-featured-badge {
        font-size: 0.8em;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    /* Styles for very small screens */
    .babyt-product-media-manager {
        padding: 10px;
    }
    
    .babyt-upload-dropzone {
        padding: 15px 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .babyt-media-grid {
        gap: 8px;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .babyt-media-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        padding: 6px;
    }
    
    .babyt-media-actions button,
    .babyt-media-actions .babyt-featured-badge {
        width: 100%;
        min-width: unset;
        padding: 8px;
        font-size: 0.9em;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
    }
}

/* Loading States */
.babyt-media-item.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.babyt-media-item.is-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Accessibility Improvements */
.babyt-media-actions button:focus-visible,
.babyt-upload-dropzone:focus-visible {
    outline: 2px solid var(--babyt-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Print Styles */
@media print {
    .babyt-upload-dropzone,
    .babyt-media-actions button {
        display: none;
    }
    
    .babyt-media-grid {
        gap: 10px;
        grid-template-columns: repeat(3, 1fr);
    }
} 