/**
 * Responsive Images and Media Styles
 * Ensures images scale properly and load efficiently on mobile devices
 * Requirements: 11.1, 11.2, 11.3, 11.4
 */

/* ============================================
   Base Image Styles
   ============================================ */

/* Ensure all images scale proportionally within containers */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Inline images should not be block */
p img,
span img,
a img {
    display: inline-block;
    vertical-align: middle;
}

/* ============================================
   Lightbox and Modal Images
   ============================================ */

/* Lightbox images should fit within viewport */
#lightboxImage,
.lightbox-image,
.modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    width: auto;
    height: auto;
}

/* ============================================
   Icon Sizing Consistency
   ============================================ */

/* Font Awesome icons - ensure consistent sizing */
i.fas,
i.far,
i.fab,
i.fal {
    min-width: 16px;
    min-height: 16px;
    font-size: 1rem; /* 16px base */
    display: inline-block;
    text-align: center;
}

/* Small icons */
i.fa-sm,
.icon-sm i {
    font-size: 0.875rem; /* 14px */
    min-width: 14px;
    min-height: 14px;
}

/* Large icons */
i.fa-lg,
.icon-lg i {
    font-size: 1.25rem; /* 20px */
    min-width: 20px;
    min-height: 20px;
}

/* Extra large icons */
i.fa-2x,
.icon-xl i {
    font-size: 1.5rem; /* 24px */
    min-width: 24px;
    min-height: 24px;
}

/* Icon buttons - ensure adequate touch targets */
.btn-icon i,
button i {
    font-size: 1rem;
    min-width: 16px;
    min-height: 16px;
}

/* Sidebar icons */
.sidebar-logo i {
    font-size: 1.5rem; /* 24px */
    min-width: 24px;
    min-height: 24px;
}

.storage-header i {
    font-size: 1.125rem; /* 18px */
    min-width: 18px;
    min-height: 18px;
}

/* Notification bell icon */
.notification-bell i {
    font-size: 1.125rem; /* 18px */
    min-width: 18px;
    min-height: 18px;
}

/* Profile dropdown icon */
.profile-dropdown i {
    font-size: 0.875rem; /* 14px */
    min-width: 14px;
    min-height: 14px;
}

/* Modal close icons */
.modal-close i {
    font-size: 1.25rem; /* 20px */
    min-width: 20px;
    min-height: 20px;
}

/* ============================================
   SVG Icons
   ============================================ */

svg {
    max-width: 100%;
    height: auto;
}

/* Inline SVG icons */
.icon-svg,
.svg-icon {
    width: 1rem;
    height: 1rem;
    display: inline-block;
    vertical-align: middle;
}

/* ============================================
   Avatar Images
   ============================================ */

.profile-avatar,
.user-avatar,
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Small avatars */
.avatar-sm {
    width: 32px;
    height: 32px;
}

/* Large avatars */
.avatar-lg {
    width: 56px;
    height: 56px;
}

/* ============================================
   Loading Spinner Icons
   ============================================ */

.fa-spinner,
.loading-spinner i {
    font-size: 1.5rem; /* 24px */
    min-width: 24px;
    min-height: 24px;
}

.btn-spinner {
    font-size: 1rem; /* 16px */
    min-width: 16px;
    min-height: 16px;
    margin-left: 0.5rem;
}

/* ============================================
   Responsive Image Adjustments
   ============================================ */

/* Mobile (< 640px) - Base styles above apply */

/* Tablet (640px+) */
@media (min-width: 640px) {
    /* Slightly larger icons on tablet */
    i.fas,
    i.far,
    i.fab,
    i.fal {
        font-size: 1.0625rem; /* 17px */
    }
    
    .sidebar-logo i {
        font-size: 1.625rem; /* 26px */
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    /* Standard icon sizes on desktop */
    i.fas,
    i.far,
    i.fab,
    i.fal {
        font-size: 1.125rem; /* 18px */
    }
    
    .sidebar-logo i {
        font-size: 1.75rem; /* 28px */
    }
    
    /* Lightbox images can be larger on desktop */
    #lightboxImage,
    .lightbox-image,
    .modal-image {
        max-height: 80vh;
    }
}

/* ============================================
   Image Performance Optimizations
   ============================================ */

/* Images with lazy loading attribute */
img[loading="lazy"] {
    /* Ensure smooth appearance when loaded */
    transition: opacity 0.3s ease-in-out;
}

/* Placeholder for lazy-loaded images */
img[loading="lazy"]:not([src]) {
    opacity: 0;
}

/* ============================================
   Print Styles for Images
   ============================================ */

@media print {
    img {
        max-width: 100%;
        page-break-inside: avoid;
    }
    
    /* Hide decorative icons when printing */
    .fa-chevron-down,
    .fa-chevron-up,
    .fa-chevron-left,
    .fa-chevron-right {
        display: none;
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* Ensure images have proper alt text handling */
img:not([alt]) {
    /* Visual indicator for missing alt text in development */
    outline: 2px dashed red;
}

/* Hide decorative images from screen readers */
img[alt=""],
img[role="presentation"] {
    outline: none;
}

/* ============================================
   Image Aspect Ratio Utilities
   ============================================ */

.img-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.img-contain {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

.img-fill {
    object-fit: fill;
    width: 100%;
    height: 100%;
}

/* ============================================
   Responsive Image Containers
   ============================================ */

.img-container {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.img-container img {
    display: block;
    width: 100%;
    height: auto;
}

/* 16:9 aspect ratio */
.img-container-16-9 {
    padding-bottom: 56.25%;
}

/* 4:3 aspect ratio */
.img-container-4-3 {
    padding-bottom: 75%;
}

/* 1:1 aspect ratio (square) */
.img-container-1-1 {
    padding-bottom: 100%;
}

.img-container-16-9 img,
.img-container-4-3 img,
.img-container-1-1 img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
