/**
 * PopRace.org - Sub-Collections UI Styles
 * 
 * Styling for sub-collections sidebar and modals.
 * V21 Design System: Navy (#1e3a5f, #0f1e2e), Gold (#d4a574, #f4c430), Cream (#f5e6d3)
 * 
 * @version 1.0.0
 */

/* ==========================================================================
   Sub-Collections Sidebar
   ========================================================================== */

/* Fix: match dark theme and design system */
.collection-sub-collections {
    background: var(--navy);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: var(--cream);
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sub-collections-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gold);
}

.sub-collections-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--cream);
    margin: 0;
}

.create-sub-collection-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    color: var(--dark-navy);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.create-sub-collection-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
}

.create-sub-collection-btn:active {
    transform: translateY(0);
}

.create-sub-collection-btn .icon {
    font-size: 18px;
    line-height: 1;
}

/* Empty State */
.sub-collections-empty {
    text-align: center;
    padding: 32px 16px;
}

.sub-collections-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.sub-collections-empty .empty-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--cream);
    margin-bottom: 6px;
}

.sub-collections-empty .empty-hint {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

/* Sub-Collection List */
.sub-collections-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sub-collection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--navy-light);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.sub-collection-item:hover {
    background: rgba(212, 165, 116, 0.15);
    border-color: var(--gold);
    transform: translateX(2px);
}

.sub-collection-item.active {
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.15), rgba(244, 196, 48, 0.15));
    border-color: var(--bright-gold);
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.2);
}

.sub-collection-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--gold), var(--bright-gold));
    border-radius: 8px 0 0 8px;
}

/* Sub-Collection Icon */
.sc-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.sub-collection-item:hover .sc-icon {
    transform: scale(1.1);
}

/* Sub-Collection Info */
.sc-info {
    flex: 1;
    min-width: 0;
}

.sc-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sc-count {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* Sub-Collection Actions */
.sc-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sub-collection-item:hover .sc-actions {
    opacity: 1;
}

.sc-edit-btn,
.sc-delete-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    border: 1px solid var(--gold);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--cream);
}

.sc-edit-btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--dark-navy);
    transform: scale(1.1);
}

.sc-delete-btn:hover {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
    transform: scale(1.1);
}

/* ==========================================================================
   Sub-Collection Modal
   ========================================================================== */

.sub-collection-modal {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.sub-collection-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Icon Picker */
.icon-picker-container {
    margin-top: 8px;
}

.icon-picker-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    width: 100%;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-picker-btn:hover {
    background: var(--cream);
    border-color: var(--gold);
}

.icon-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.icon-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--navy);
}

/* Color Picker */
.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-swatch.active {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy);
}

.color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.color-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.color-custom input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.color-custom label {
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
}

/* ==========================================================================
   Icon Picker Modal
   ========================================================================== */

.icon-picker-modal {
    width: 90%;
    max-width: 450px;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.icon-option {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-option:hover {
    background: var(--cream);
    border-color: var(--gold);
    transform: scale(1.1);
}

.icon-option.active {
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    border-color: var(--bright-gold);
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.4);
}

.icon-custom {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.icon-custom label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--navy);
    margin-bottom: 8px;
}

.icon-custom input {
    width: 100%;
    padding: 10px;
    font-size: 24px;
    text-align: center;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.icon-custom input:focus {
    outline: none;
    border-color: var(--gold);
}

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

@media (max-width: 768px) {
    .collection-sub-collections {
        padding: 12px;
    }
    
    .sub-collections-header h3 {
        font-size: 14px;
    }
    
    .create-sub-collection-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    .create-sub-collection-btn .text {
        display: none;
    }
    
    .sub-collection-item {
        padding: 8px;
        gap: 10px;
    }
    
    .sc-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .sc-name {
        font-size: 13px;
    }
    
    .sc-count {
        font-size: 11px;
    }
    
    .sc-actions {
        opacity: 1; /* Always visible on mobile */
    }
    
    .sc-edit-btn,
    .sc-delete-btn {
        width: 32px;
        height: 32px;
    }
    
    .sub-collection-modal {
        width: 95%;
        max-width: none;
    }
    
    .color-swatches {
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
        gap: 6px;
    }
    
    .color-swatch {
        width: 36px;
        height: 36px;
    }
    
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 6px;
    }
    
    .icon-option {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .sub-collections-empty {
        padding: 24px 12px;
    }
    
    .sub-collections-empty .empty-icon {
        font-size: 40px;
    }
    
    .sub-collections-empty .empty-text {
        font-size: 14px;
    }
    
    .sub-collections-empty .empty-hint {
        font-size: 12px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .sub-collection-item {
        border-width: 3px;
    }
    
    .sc-icon {
        border: 2px solid currentColor;
    }
    
    .color-swatch {
        border-width: 4px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .sub-collection-item,
    .sc-icon,
    .sc-edit-btn,
    .sc-delete-btn,
    .create-sub-collection-btn,
    .color-swatch,
    .icon-option {
        transition: none;
    }
}

/* Focus Visible */
.sub-collection-item:focus-visible,
.create-sub-collection-btn:focus-visible,
.sc-edit-btn:focus-visible,
.sc-delete-btn:focus-visible,
.icon-picker-btn:focus-visible,
.color-swatch:focus-visible,
.icon-option:focus-visible {
    outline: 3px solid var(--bright-gold);
    outline-offset: 2px;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

.collection-sub-collections::-webkit-scrollbar {
    width: 6px;
}

.collection-sub-collections::-webkit-scrollbar-track {
    background: rgba(212, 165, 116, 0.1);
    border-radius: 3px;
}

.collection-sub-collections::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 3px;
}

.collection-sub-collections::-webkit-scrollbar-thumb:hover {
    background: var(--cream);
}
