/**
 * Guestbook Photo Gallery CSS
 * Responsive design for photo uploads in guestbook entries
 *
 * @author Claude Code
 * @date 2025-10-22
 */

/* ==========================================
   Photo Gallery Container
   ========================================== */

.gb-entry-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.gb-entry-photos:empty {
    display: none;
}

/* ==========================================
   Photo Thumbnails
   ========================================== */

.gb-photo-thumb {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 2px solid #fff;
}

.gb-photo-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #FF9900;
}

.gb-photo-thumb:active {
    transform: scale(0.98);
}

/* ==========================================
   Photo Link Wrapper
   ========================================== */

.gb-photo-link {
    position: relative;
    display: inline-block;
}

.gb-photo-link::after {
    content: '\1F50D';  /* Magnifying glass emoji */
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gb-photo-link:hover::after {
    opacity: 1;
}

/* ==========================================
   Photo Count Badge
   ========================================== */

.gb-photo-count {
    display: inline-block;
    margin: 10px 0 5px 0;
    padding: 5px 10px;
    background: #FF9900;
    color: white;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
}

/* ==========================================
   Photo Upload Form Elements
   ========================================== */

.photo-upload-container {
    margin: 15px 0;
    padding: 15px;
    background: #f0f8ff;
    border: 2px dashed #FF9900;
    border-radius: 8px;
}

.photo-upload-input {
    display: none;
}

.photo-upload-label {
    display: inline-block;
    padding: 10px 20px;
    background: #FF9900;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-weight: bold;
}

.photo-upload-label:hover {
    background: #E68A00;
}

.photo-upload-label:active {
    background: #CC7A00;
}

.photo-upload-help {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.photo-upload-formats {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* ==========================================
   Photo Preview (before upload)
   ========================================== */

.photo-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 15px; /* Add spacing below to prevent overlap */
}

.photo-preview-item {
    position: relative;
    width: 120px;
    height: auto; /* Changed from 120px to auto to accommodate filename */
    display: flex;
    flex-direction: column;
}

.photo-preview-img {
    width: 100%;
    height: 120px; /* Fixed height for image only */
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.photo-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ff4444;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    transition: background 0.3s ease;
}

.photo-preview-remove:hover {
    background: #cc0000;
}

.photo-preview-filename {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    color: #666;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================
   Storage Info
   ========================================== */

.photo-storage-info {
    margin: 10px 0;
    padding: 10px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    font-size: 13px;
}

.photo-storage-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

.photo-storage-used {
    height: 100%;
    background: linear-gradient(90deg, #4caf50 0%, #ff9800 70%, #f44336 100%);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: bold;
}

.photo-storage-warning {
    color: #856404;
    font-weight: bold;
    margin-top: 5px;
}

/* ==========================================
   Error Messages
   ========================================== */

.photo-error {
    margin: 10px 0;
    padding: 10px;
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
    color: #721c24;
    font-size: 13px;
}

.photo-success {
    margin: 10px 0;
    padding: 10px;
    background: #d4edda;
    border-left: 4px solid #28a745;
    border-radius: 4px;
    color: #155724;
    font-size: 13px;
}

/* ==========================================
   Responsive Design
   ========================================== */

/* Mobile (< 480px) */
@media (max-width: 480px) {
    .gb-entry-photos {
        gap: 5px;
        padding: 10px;
    }

    .gb-photo-thumb {
        width: calc(33.33% - 5px);
        height: auto;
        aspect-ratio: 1;
    }

    .photo-upload-container {
        padding: 10px;
    }

    .photo-preview-item {
        width: 80px;
        height: auto; /* Changed to auto to accommodate filename */
    }

    .photo-preview-img {
        height: 80px; /* Image height for mobile */
    }
}

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .gb-photo-thumb {
        width: calc(25% - 10px);
        height: auto;
        aspect-ratio: 1;
    }
}

/* Desktop (> 768px) */
@media (min-width: 769px) {
    .gb-entry-photos {
        max-width: 800px;
    }

    .gb-photo-thumb {
        width: 180px;
        height: 180px;
    }
}

/* ==========================================
   Loading State
   ========================================== */

.photo-loading {
    display: inline-block;
    width: 150px;
    height: 150px;
    background: #f0f0f0;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

.photo-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150px;
    width: 150px;
    height: 150px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -150px;
    }
    100% {
        left: 150px;
    }
}

/* ==========================================
   Temporary Uploads Display (Vertical Layout)
   ========================================== */

.temp-uploads {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.temp-uploads strong {
    display: block;
    margin-bottom: 12px;
    color: #495057;
    font-size: 14px;
}

.temp-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.temp-photo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.temp-photo-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.temp-photo-preview {
    width: 120px;
    height: 120px;
    background: #e9ecef;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    overflow: hidden;
}

.temp-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.temp-photo-info {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.temp-photo-name {
    font-size: 12px;
    color: #212529;
    word-break: break-word;
    margin-bottom: 4px;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.temp-photo-size {
    font-size: 11px;
    color: #6c757d;
}

.delete-temp-photo {
    width: 100%;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.delete-temp-photo:hover {
    background: #c82333;
}

.delete-temp-photo:active {
    background: #bd2130;
    transform: scale(0.98);
}

.temp-upload-errors {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
}

.temp-upload-errors p {
    color: #721c24;
    font-size: 12px;
    margin: 4px 0;
}

/* ==========================================
   Responsive Adjustments for Temp Uploads
   ========================================== */

/* Mobile (< 480px) */
@media (max-width: 480px) {
    .temp-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .temp-photo-item {
        padding: 10px;
    }

    .temp-photo-preview {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }

    .temp-photo-name {
        font-size: 11px;
    }

    .delete-temp-photo {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .temp-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
        gap: 12px;
    }
}

/* Desktop (> 768px) */
@media (min-width: 769px) {
    .temp-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 18px;
    }

    .temp-photo-preview {
        width: 140px;
        height: 140px;
    }
}

/* ==========================================
   Print Styles
   ========================================== */

@media print {
    .gb-entry-photos {
        break-inside: avoid;
    }

    .gb-photo-thumb {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .photo-upload-container,
    .photo-preview-container,
    .photo-storage-info,
    .temp-uploads {
        display: none;
    }
}
