* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #fff;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

h1 {
    font-size: 28px;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button, select {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

button {
    background: #2563eb;
    color: white;
    font-weight: 500;
}

button:hover {
    background: #1d4ed8;
}

button:disabled {
    background: #4b5563;
    cursor: not-allowed;
}

select {
    background: #2d2d2d;
    color: white;
    border: 1px solid #404040;
    min-width: 200px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.media-item {
    position: relative;
    aspect-ratio: 1;
    background: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.media-item:hover {
    transform: scale(1.02);
}

.media-item img,
.media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-item video {
    opacity: 0;
    transition: opacity 0.3s;
}

.media-item:hover video {
    opacity: 1;
}

.media-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 15px 10px 10px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-item:hover .media-info {
    opacity: 1;
}

.collections-badge {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.badge {
    background: #2563eb;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2d2d2d;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
}

.modal h2 {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #404040;
    border-radius: 6px;
    background: #1a1a1a;
    color: white;
    font-size: 14px;
}

.checkbox-group {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 10px;
    background: #1a1a1a;
}

.checkbox-item {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background: #4b5563;
}

.btn-secondary:hover {
    background: #374151;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #888;
}

/* Media Viewer Styles */
.media-viewer-container {
    position: relative;
    background: #1a1a1a;
    border-radius: 12px;
    max-width: 1400px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
}

.close-viewer {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 24px;
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-viewer:hover {
    background: rgba(0, 0, 0, 0.9);
}

.viewer-content {
    display: flex;
    height: 90vh;
    max-height: 90vh;
}

.viewer-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: 20px;
    overflow: hidden;
}

.viewer-media img,
.viewer-media video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.viewer-sidebar {
    width: 350px;
    background: #2d2d2d;
    padding: 60px 25px 25px 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.viewer-sidebar h3 {
    font-size: 18px;
    margin-bottom: 20px;
    word-break: break-word;
}

.viewer-section {
    margin-bottom: 20px;
}

.viewer-section h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.viewer-save-btn {
    margin-top: auto;
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    h1 {
        font-size: 30px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .controls {
        flex-direction: column;
    }

    button, select {
        width: 100%;
    }

    .viewer-content {
        flex-direction: column;
        height: auto;
        max-height: 90vh;
    }

    .viewer-media {
        height: 50vh;
        min-height: 300px;
    }

    .viewer-sidebar {
        width: 100%;
        max-height: 40vh;
        padding-top: 25px;
    }

    .close-viewer {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
}