/* Cloud Browser Styles */

.cloud-container {
    min-height: 100vh;
    background: #f8f9fa;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Header */
.cloud-header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cloud-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Thumbnail Size Selector */
.thumbnail-size-selector {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.size-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px 12px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-width: 32px;
}

/* Different font sizes and padding for S, M, L buttons */
.size-btn[data-size="small"] {
    font-size: 11px;
    padding: 2px 4px;
}

.size-btn[data-size="medium"] {
    font-size: 13px;
    padding: 3px 5px;
}

.size-btn[data-size="large"] {
    font-size: 15px;
    padding: 4px 7px;
}

.size-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.size-btn.active {
    background: white;
    color: #007AFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.size-btn:active {
    transform: scale(0.95);
}

/* Fit/Fill Mode Selector */
.fit-mode-selector {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.fit-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-width: 40px;
}

.fit-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.fit-btn.active {
    background: white;
    color: #007AFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.fit-btn:active {
    transform: scale(0.95);
}

.photo-count {
    font-size: 0.95rem;
    color: #666;
    font-weight: 500;
}

.sign-out-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.sign-out-btn:hover {
    color: #ff6b35;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    gap: 1rem;
}

.back-btn {
    background: none;
    border: none;
    color: #007AFF;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.back-btn:hover {
    opacity: 0.7;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.breadcrumb-item {
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.breadcrumb-item:hover:not(.active) {
    color: #ff6b35;
}

.breadcrumb-item.active {
    color: #333;
    font-weight: 600;
    pointer-events: none;
}

.breadcrumb-separator {
    color: #999;
    margin: 0 0.25rem;
}

/* Main Content */
.cloud-main {
    padding: 1rem;
    max-width: none;  /* Use full width for collection view */
    margin: 0 auto;
    background: #f5f5f5;  /* Light gray background like native apps */
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Error State */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-container h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

.error-message {
    color: #666;
    margin-bottom: 1.5rem;
}

.retry-btn {
    background: #ff6b35;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #e55a2b;
}

/* Years Container */
.years-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 320px));
    gap: 1rem;
    justify-content: center;
    padding: 1rem 0;
}

/* Year Card */
.year-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 320px;  /* Limit card width */
}

.year-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.year-thumbnails {
    width: 100%;
    height: 180px;  /* Fixed height for preview */
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
    background: #e0e0e0;
    overflow: hidden;
}

.year-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.year-placeholder {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #ccc;
    background: #f8f8f8;
}

.year-info {
    padding: 1rem;
}

.year-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.25rem 0;
}

.year-count {
    color: #666;
    font-size: 0.9rem;
}

/* Collection View Container */
.collection-view {
    background: #f5f5f5;
    min-height: calc(100vh - 200px);
}

/* Photo Section */
.photo-section {
    margin-bottom: 1rem;
}

/* Section Header with Chevron */
.section-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #e8e8e8;
    border-bottom: 1px solid #d0d0d0;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.section-header:hover {
    background: #e0e0e0;
}

.section-title {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.section-header .photo-count {
    color: #666;
    font-size: 14px;
    margin-right: 8px;
}

.chevron-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    padding: 0 8px;
    cursor: pointer;
    transition: color 0.15s;
}

.chevron-btn:hover {
    color: #666;
}

/* Photos Container - Collection View Style */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 128px); /* Default: medium */
    gap: 8px;
    justify-content: center;
    padding: 8px 16px 16px 16px;
    transition: grid-template-columns 0.3s ease;
}

/* Small thumbnails (64x64) */
.photo-grid.size-small {
    grid-template-columns: repeat(auto-fill, 64px);
    gap: 4px;
}

/* Medium thumbnails (128x128) - Default */
.photo-grid.size-medium {
    grid-template-columns: repeat(auto-fill, 128px);
    gap: 8px;
}

/* Large thumbnails (256x256) */
.photo-grid.size-large {
    grid-template-columns: repeat(auto-fill, 256px);
    gap: 12px;
}

/* Photo Cell */
.photo-cell {
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
}

.photo-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.photo-thumbnail {
    width: 128px;  /* Default: medium */
    height: 128px;
    object-fit: cover;  /* Default: fill mode */
    display: block;
    background: #f8f8f8;
    transition: width 0.3s ease, height 0.3s ease, object-fit 0.3s ease;
}

/* Fit mode: scale image to fit within bounds */
.mode-fit .photo-thumbnail {
    object-fit: contain;
    background: white;  /* Match info bar background */
}

/* Fill mode: scale image to fill entire frame */
.mode-fill .photo-thumbnail {
    object-fit: cover;
}

/* Small thumbnail size */
.size-small .photo-thumbnail {
    width: 64px;
    height: 64px;
}

/* Medium thumbnail size */
.size-medium .photo-thumbnail {
    width: 128px;
    height: 128px;
}

/* Large thumbnail size */
.size-large .photo-thumbnail {
    width: 256px;
    height: 256px;
}

/* Photo Info Bar */
.photo-info {
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #666;
    background: white;
    border-top: 1px solid #f0f0f0;
}

/* Small size: stack info vertically */
.size-small .photo-info {
    flex-direction: column;
    gap: 2px;
    padding: 4px;
}

.photo-date {
    color: #999;
    font-size: 10px;
}

.photo-size {
    font-weight: 500;
    color: #666;
    font-size: 10px;
}

/* Load More */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding: 2rem 0;
}

.load-more-btn {
    background: white;
    color: #ff6b35;
    border: 2px solid #ff6b35;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-btn:hover:not(:disabled) {
    background: #ff6b35;
    color: white;
}

.load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: #333;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #666;
}

/* Responsive Design - Keep collection view style */
@media (max-width: 1024px) {
    /* iPad and smaller - use 200px thumbnails */
    .photo-grid {
        grid-template-columns: repeat(auto-fill, 200px);
    }

    .photo-thumbnail {
        width: 200px;
        height: 200px;
    }
}

@media (max-width: 768px) {
    .cloud-main {
        padding: 0.5rem;
    }

    .header-content {
        padding: 1rem;
    }

    .cloud-title {
        font-size: 1.5rem;
    }

    .breadcrumb {
        padding: 0.5rem 1rem;
    }

    .years-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    /* Use 128px thumbnails on mobile */
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 4px;
        padding: 4px;
    }

    .photo-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}

@media (max-width: 480px) {
    /* Small phones - use flexible grid */
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 2px;
    }

    .photo-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}
