* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.toggle-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

#auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#login-form {
    display: flex;
    gap: 0.5rem;
}

#login-form input {
    padding: 0.5rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

#login-form button, #logout-btn {
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

#login-form button:hover, #logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-controls select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
}

.view-controls button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.view-controls button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.view-controls button:hover {
    background: #667eea;
    color: white;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.media-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.media-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.media-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #999;
    position: relative;
    overflow: hidden;
}

.loading-thumbnail {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        background-color: #f0f0f0;
    }
    50% {
        background-color: #e0e0e0;
    }
    100% {
        background-color: #f0f0f0;
    }
}

.media-info {
    padding: 1rem;
}

.media-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-size {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.media-favorite {
    color: #ff6b6b;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Inline action buttons */
.media-actions-inline {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.media-item:hover .media-actions-inline {
    opacity: 1;
}

.media-action-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
}

.media-action-btn:hover {
    background: white;
    border-color: #999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.media-favorite-btn {
    color: #e91e63;
}

.media-favorite-btn:hover {
    background: #fce4ec;
    border-color: #e91e63;
}

.media-download-btn {
    color: #2196f3;
}

.media-download-btn:hover {
    background: #e3f2fd;
    border-color: #2196f3;
}

.media-delete-btn {
    color: #f44336;
}

.media-delete-btn:hover {
    background: #ffebee;
    border-color: #f44336;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    z-index: 1001;
}

.close:hover {
    color: #333;
}

#media-player {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    position: relative;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 1002;
    transition: background-color 0.3s;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

#modal-image, #modal-video {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.media-info {
    padding: 1rem;
    border-top: 1px solid #eee;
}

#media-path {
    font-size: 0.8rem;
    color: #666;
    font-family: monospace;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.media-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.media-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
}

.media-actions button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.media-actions button:active {
    background: #e2e8f0;
    transform: scale(0.95);
}

#favorite-btn {
    color: #ef4444;
}

#favorite-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

#favorite-btn.favorited {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
}

#favorite-btn.favorited:hover {
    background: #dc2626;
}

#download-btn {
    color: #3b82f6;
}

#download-btn:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

#delete-btn {
    color: #ef4444;
}

#delete-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* Delete confirm state styling */
.delete-confirm {
    background: #ef4444 !important;
    color: white !important;
    border-color: #dc2626 !important;
    font-weight: 600;
    animation: deleteConfirmPulse 0.3s ease;
}

@keyframes deleteConfirmPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


.separator {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 0.25rem;
}

.folder-nav-btn {
    color: #64748b;
}

.folder-nav-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.folder-nav-btn:disabled {
    background: #f8fafc;
    color: #cbd5e1;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.5;
}

.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #c62828;
    margin-bottom: 1rem;
}



@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
    }
    
    #controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .modal-content {
        max-width: 95%;
        max-height: 95%;
    }
}

/* Load More Button */
#load-more-container {
    text-align: center;
    padding: 2rem;
}

.load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.load-more-btn:active {
    transform: translateY(0);
}

/* Favorites Controls */
.favorites-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.batch-mode,
.range-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.batch-mode label,
.range-mode label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}

.batch-size-selector {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    background: white;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.batch-size-selector:hover {
    border-color: #764ba2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.batch-size-selector:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.range-input {
    width: 80px;
    padding: 0.75rem 0.75rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    background: white;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s;
    outline: none;
}

.range-input:hover {
    border-color: #764ba2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.range-input:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.range-input::placeholder {
    color: #999;
    font-weight: 400;
}

#favorites-complete-message {
    text-align: center;
    padding: 1rem;
    color: #667eea;
    font-weight: 500;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

body.dark-mode .media-item {
    background: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode .media-item:hover {
    background: #363636;
}


body.dark-mode .media-thumbnail {
    background: #404040;
}

body.dark-mode #controls {
    background: #2d2d2d;
}

body.dark-mode select {
    background: #404040;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .view-controls button {
    background: #404040;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .view-controls button.active {
    background: #667eea;
    color: white;
}

body.dark-mode .modal-content {
    background: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode .close {
    color: #e0e0e0;
}

body.dark-mode .media-actions {
    background: #1e293b;
    border-color: #374151;
}

body.dark-mode .media-actions button {
    background: #374151;
    color: #9ca3af;
    border-color: #4b5563;
}

body.dark-mode .media-actions button:hover {
    background: #4b5563;
    border-color: #6b7280;
    color: #d1d5db;
}

body.dark-mode .media-actions button:active {
    background: #374151;
}

body.dark-mode #favorite-btn {
    color: #f87171;
}

body.dark-mode #favorite-btn:hover {
    background: #431414;
    border-color: #7f1d1d;
    color: #ef4444;
}

body.dark-mode #favorite-btn.favorited {
    background: #dc2626;
    color: white;
    border-color: #b91c1c;
}

body.dark-mode #favorite-btn.favorited:hover {
    background: #b91c1c;
}

body.dark-mode #download-btn {
    color: #60a5fa;
}

body.dark-mode #download-btn:hover {
    background: #1e3a8a;
    border-color: #3730a3;
    color: #93c5fd;
}

body.dark-mode #delete-btn {
    color: #f87171;
}

body.dark-mode #delete-btn:hover {
    background: #431414;
    border-color: #7f1d1d;
    color: #ef4444;
}

body.dark-mode .batch-mode label,
body.dark-mode .range-mode label {
    color: #b0b0b0;
}

body.dark-mode .batch-size-selector {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #667eea;
}

body.dark-mode .batch-size-selector:hover {
    background: #333;
    border-color: #764ba2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

body.dark-mode .batch-size-selector:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

body.dark-mode .range-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #667eea;
}

body.dark-mode .range-input:hover {
    background: #333;
    border-color: #764ba2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

body.dark-mode .range-input:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

body.dark-mode .range-input::placeholder {
    color: #666;
}

body.dark-mode #favorites-complete-message {
    color: #93c5fd;
}

/* Dark mode delete confirm state */
body.dark-mode .delete-confirm {
    background: #ef4444 !important;
    color: white !important;
    border-color: #dc2626 !important;
}


body.dark-mode .separator {
    background: #4b5563;
}

body.dark-mode #media-path {
    color: #aaa;
}

body.dark-mode .error {
    background: #4a2c2c;
    color: #ffaaaa;
    border-left-color: #ff6b6b;
}

body.dark-mode .load-more-btn {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    box-shadow: 0 4px 15px rgba(74, 85, 104, 0.4);
}

body.dark-mode .load-more-btn:hover {
    box-shadow: 0 6px 20px rgba(74, 85, 104, 0.6);
}

/* Dark mode for inline action buttons */
body.dark-mode .media-action-btn {
    background: rgba(45, 45, 45, 0.9);
    border-color: #555;
}

body.dark-mode .media-action-btn:hover {
    background: #404040;
    border-color: #777;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .media-favorite-btn:hover {
    background: #4a2c2c;
    border-color: #e91e63;
}

body.dark-mode .media-download-btn:hover {
    background: #1a2332;
    border-color: #2196f3;
}

body.dark-mode .media-delete-btn:hover {
    background: #4a2c2c;
    border-color: #f44336;
}

/* Album Selector Modal */
.album-selector {
    width: 400px;
    max-height: 500px;
}

.album-selector h3 {
    margin-bottom: 1rem;
    text-align: center;
    color: #333;
}

#album-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.album-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.album-item:hover {
    background: #f0f0f0;
    border-color: #667eea;
}

.album-item.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.album-icon {
    font-size: 1.5rem;
    margin-right: 1rem;
}

.album-info {
    flex: 1;
}

.album-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.album-path {
    font-size: 0.8rem;
    color: #888;
    font-family: monospace;
    margin: 0.2rem 0;
}

.album-count {
    font-size: 0.8rem;
    color: #666;
}

.album-item.selected .album-count {
    color: rgba(255, 255, 255, 0.8);
}

.album-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.album-actions button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.album-actions button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

#add-to-selected-album {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

#add-to-selected-album:hover {
    background: #5a6fd8;
    border-color: #5a6fd8;
}

#add-to-selected-album:disabled {
    background: #ccc;
    color: #666;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Dark mode for album selector */
body.dark-mode .album-selector h3 {
    color: #e0e0e0;
}

body.dark-mode .album-item {
    background: #404040;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .album-item:hover {
    background: #4a4a4a;
    border-color: #667eea;
}

body.dark-mode .album-count {
    color: #aaa;
}

body.dark-mode .album-actions {
    border-top-color: #555;
}

body.dark-mode .album-actions button {
    background: #404040;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .folder-nav-btn {
    color: #9ca3af;
}

body.dark-mode .folder-nav-btn:hover:not(:disabled) {
    background: #4b5563;
    border-color: #6b7280;
    color: #d1d5db;
}

body.dark-mode .folder-nav-btn:disabled {
    background: #1f2937;
    color: #6b7280;
    border-color: #374151;
    opacity: 0.5;
}
