@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    font-family: 'Inter', sans-serif;
}

.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.glass-effect {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Tambahkan style untuk tombol auth baru */
.auth-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(102, 126, 234, 0.5);
}

.auth-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.auth-btn-secondary:hover {
    background: #e5e7eb;
}

.auth-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 0.5rem;
    color: #4c1d95;
    font-weight: 500;
}

.user-role-badge {
    background: #10b981;
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.upload-area {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border: 2px dashed #667eea;
    transition: all 0.3s ease;
}

.upload-area.dragover {
    background: linear-gradient(135deg, #667eea35 0%, #764ba235 100%);
    border-color: #764ba2;
    transform: scale(1.02);
}

.toast {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-card {
    transition: all 0.3s ease;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.copy-btn {
    transition: all 0.2s ease;
}

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

.copy-btn.copied {
    background-color: #10b981 !important;
}

.tab-active {
    border-bottom: 3px solid #667eea;
    color: #667eea;
}

.image-wrapper {
    position: relative;
    overflow: hidden;
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-card:hover .image-overlay {
    opacity: 1;
}

.progress-bar {
    transition: width 0.3s ease;
}

.domain-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.url-preview {
    font-family: 'Courier New', monospace;
    background: #f3f4f6;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.compression-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

.compression-slider:hover {
    opacity: 1;
}

.compression-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.compression-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.compression-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-size: 13px;
}

.compression-success {
    color: #059669;
}

.compression-warning {
    color: #d97706;
}

.debug-info {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    padding: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #92400e;
}

.refresh-btn {
    animation: spin 2s linear infinite;
}

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

.refresh-btn:not(.loading) {
    animation: none;
}

/* Modern Modal Styles */
.modern-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modern-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.modern-modal:hover .modal-header {
    opacity: 1;
    transform: translateY(0);
}

.modal-title {
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    overflow: hidden;
    position: relative;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    opacity: 0;
}

.modern-modal.active .modal-image {
    transform: scale(1);
    opacity: 1;
}

.modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 1.5rem 2rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.modern-modal:hover .modal-footer {
    opacity: 1;
    transform: translateY(0);
}

.modal-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
}

.modal-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-info-item i {
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(102, 126, 234, 0.5);
}

.modal-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-btn-danger {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.modal-btn-danger:hover {
    background: rgba(239, 68, 68, 1);
    transform: translateY(-2px);
}

.modal-link-container {
    display: none;
    position: absolute;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 400px;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.3s ease;
}

.modal-link-container.show {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.modal-link-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
}

.modal-link-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Loading Spinner - IMPROVED */
.modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20; /* Increased z-index */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 1.5rem;
    border-radius: 0.75rem;
    min-width: 150px;
}

.modal-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.modal-loading-text {
    color: white;
    margin-top: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .modal-info {
        justify-content: center;
        gap: 1rem;
    }
    
    .modal-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .modal-image-container {
        padding: 3rem 1rem;
    }
    
    .modal-link-container {
        min-width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
        transform: none;
    }
    
    .modal-link-container.show {
        transform: translateY(0);
    }
}

/* Zoom functionality */
.modal-image.zoomed {
    cursor: zoom-out;
}

.zoom-indicator {
    position: absolute;
    top: 1rem;
    right: 4rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.zoom-indicator.show {
    opacity: 1;
}

/* Admin Login Modal */
.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.admin-modal.active {
    opacity: 1;
    visibility: visible;
}

.admin-modal-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.admin-modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.admin-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.admin-modal-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.admin-input {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.admin-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.admin-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.admin-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.admin-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.admin-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(102, 126, 234, 0.5);
}

.admin-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.admin-btn-secondary:hover {
    background: #e5e7eb;
}

/* --- Perbaikan Header Galeri untuk Mobile --- */
@media (max-width: 768px) {
    /* Cari div yang berisi judul dan kontrol */
    #gallerySection .flex.items-center.justify-between.mb-8 {
        flex-direction: column; /* Tumpuk ke atas, bukan samping-menyamping */
        align-items: flex-start; /* Ratakan ke kiri */
        gap: 1rem; /* Beri jarak antara judul dan kontrol */
    }

    /* Buat container untuk kontrol menjadi full width dan rata tengah isinya */
    #gallerySection .flex.items-center.space-x-4 {
        width: 100%;
        justify-content: center; /* Ratakan search dan sort ke tengah */
        flex-wrap: wrap; /* Biarkan pindah ke baris baru jika kurang lebar */
        gap: 0.75rem; /* Beri jarak horizontal */
    }

    /* Buat input dan select memenuhi lebar yang tersedia */
    #gallerySection #searchInput,
    #gallerySection #sortSelect {
        flex: 1;
        min-width: 150px; /* Lebar minimum agar tidak terlalu kecil */
    }
}

/* --- Perbaikan Tampilan <select> untuk Safari dan Browser Lainnya --- */
.custom-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #ffffff;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 0.5rem; /* rounded-lg */
    padding-left: 1rem; /* px-4 */
    padding-right: 2.5rem; /* Ruang ekstra di kanan untuk panah */
    padding-top: 0.5rem; /* py-2 */
    padding-bottom: 0.5rem;
    font-size: 0.875rem; /* text-sm */
    line-height: 1.25rem;
}

/* Gaya saat fokus */
.custom-select:focus {
    outline: none;
    border-color: #9333ea; /* purple-600 */
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1); /* Ring fokus ungu */
}

/* Panah dropdown kustom */
.custom-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.7rem center;
    background-repeat: no-repeat;
    background-size: 1.2em 1.2em;
}

/* Admin Badge */
.admin-badge {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}
/* Responsive Button Styles */
.flex-1.min-w-\[100px\] {
    flex: 1;
    min-width: 100px;
}

/* Ensure buttons inside the card have consistent height */
.image-card .flex button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px; /* Atur tinggi yang konsisten */
}