/* Photo Selection - Main Application Core Stylesheet */
/* Extracted from app.html (Phase 5.0C) */

@import url('https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,opsz,wght@0,6..96,400;0,6..96,700;1,6..96,400;1,6..96,700&family=Cormorant+Garamond:ital,wght@0,400;0,700;1,400;1,700&family=DM+Serif+Display:ital@0;1&family=Great+Vibes&family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&family=Manrope:wght@400;500;600;700;800&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Lora:ital,wght@0,400;0,700;1,400;1,700&family=Montserrat:ital,wght@0,400;0,700;1,400;1,700&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@import url('./design-tokens.css');
@import url('./role-shell.css');
@import url('./auth-luxury.css');
@import url('./client-gallery-luxury.css');

body {
    background-color: #f8fafc;
    font-family: 'Inter', sans-serif;
    color: #0f172a;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Phase 2: Watermark Dinamis — Isolated to Photographic Media Region */
.photo-media-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-media-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Watermark strictly restricted to photographic media region, cut off above action bar and filename */
.has-watermark .photo-card:not(.is-folder) .photo-media-wrapper::after,
.has-watermark .photo-card:not(.is-folder):not(:has(.photo-media-wrapper))::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--watermark-bottom-cutoff, 72px);
    pointer-events: none !important;
    background-image: var(--watermark-bg);
    background-position: top left;
    background-repeat: repeat;
    z-index: 2;
    clip-path: inset(0 0 0 0);
}

@media (max-width: 640px) {
    .has-watermark .photo-card:not(.is-folder) .photo-media-wrapper::after,
    .has-watermark .photo-card:not(.is-folder):not(:has(.photo-media-wrapper))::after {
        bottom: 56px;
    }
}

/* Isolate info-overlay, filename, and action toolbar in elevated stacking context */
.photo-card .info-overlay,
#client-gallery-view .photo-card .info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25 !important;
    pointer-events: none;
}

.photo-card .info-overlay * {
    pointer-events: auto;
}

.photo-card .photo-card-name-row,
#client-gallery-view .photo-card .photo-card-name-row {
    position: relative;
    z-index: 26 !important;
}

.photo-card .photo-card-action-row,
#client-gallery-view .photo-card .photo-card-action-row {
    position: relative;
    z-index: 26 !important;
}

/* Prevent watermark showing through semitransparent buttons */
.photo-card .btn-pilih-download,
.photo-card .btn-direct-download,
.photo-card .btn-pilih-foto,
#client-gallery-view .photo-card .btn-pilih-foto,
#client-gallery-view .photo-card .btn-pilih-download,
#client-gallery-view .photo-card .btn-direct-download {
    position: relative;
    z-index: 27 !important;
    isolation: isolate;
}

/* Badges elevated above watermark */
.photo-card .number-badge,
#client-gallery-view .photo-card .number-badge,
.photo-card .check-badge,
#client-gallery-view .photo-card .check-badge,
.photo-card .heart-btn,
#client-gallery-view .photo-card .heart-btn {
    z-index: 30 !important;
    pointer-events: auto !important;
}

/* Fullscreen viewer watermark containment */
.has-watermark #viewerImageWrapper {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.has-watermark #viewerImageWrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none !important;
    background-image: var(--watermark-bg);
    background-position: top left;
    background-repeat: repeat;
    z-index: 2;
}

/* PREMIUM UI UPGRADES (Landing Page Match) */
.glass-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 40;
}

.bg-white.rounded-2xl {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    border-color: #f1f5f9;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.bg-white.rounded-2xl:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 700 !important;
}

/* Adaptive Grid Layout */
.adaptive-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
}

.adaptive-grid::after {
    content: '';
    flex-grow: 999999999;
    min-width: 200px;
    height: 0;
}

.adaptive-card {
    flex-grow: 1;
    height: 300px;
    position: relative;
    border-radius: 0.75rem;
    overflow: hidden;
    aspect-ratio: auto !important;
}

.adaptive-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 640px) {
    .adaptive-card {
        height: 180px;
    }
}

/* Fix Aspect Ratio for non-square layouts */
.masonry-card {
    aspect-ratio: auto !important;
    height: auto !important;
}

.masonry-card img {
    height: auto !important;
    position: static !important;
}

.horizontal-card,
.slideshow-card {
    aspect-ratio: auto !important;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: #f1f5f9 !important;
}

.hero-pattern-bg {
    background-color: #f8fafc;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 32px 32px;
}

.view-section {
    display: none;
    height: 100%;
    width: 100%;
    flex-direction: column;
}

.view-section.active {
    display: flex;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.scrollable-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scrollable-content::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

#global-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-surface, var(--panel, rgba(14, 15, 16, 0.94)));
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    transition: opacity 0.25s ease;
}

[data-theme="ivory"] #global-loader,
html[data-theme="ivory"] #global-loader {
    background: rgba(245, 241, 233, 0.96);
}

[data-theme="noir"] #global-loader,
html[data-theme="noir"] #global-loader {
    background: rgba(14, 15, 16, 0.95);
}

[data-theme="sapphire"] #global-loader,
html[data-theme="sapphire"] #global-loader {
    background: rgba(10, 17, 32, 0.95);
}

[data-theme="olive"] #global-loader,
html[data-theme="olive"] #global-loader {
    background: rgba(233, 235, 229, 0.96);
}

#loader-text {
    color: var(--text, #0f172a) !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    letter-spacing: 0.15em !important;
    margin-top: 12px !important;
    opacity: 0.95 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="ivory"] #loader-text,
html[data-theme="ivory"] #loader-text {
    color: #27231e !important;
    text-shadow: none !important;
}

[data-theme="olive"] #loader-text,
html[data-theme="olive"] #loader-text {
    color: #203327 !important;
    text-shadow: none !important;
}

[data-theme="noir"] #loader-text,
html[data-theme="noir"] #loader-text {
    color: #f4f0e9 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="sapphire"] #loader-text,
html[data-theme="sapphire"] #loader-text {
    color: #f0f5ff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

/* Grid responsif otomatis: 2-3 kolom di HP, lebih banyak di Tablet/PC */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 10px;
    padding: 12px;
}

@media (min-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

.photo-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 2px solid transparent;
    /* Akselerasi GPU untuk hilangkan Lag di HP */
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    will-change: transform, box-shadow, border-color;
    transform: translateZ(0);
}

.photo-card:hover {
    transform: translateY(-3px) translateZ(0);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #ececf1;
    transition: transform 0.3s ease, filter 0.3s ease;
    will-change: transform, filter;
    transform: translateZ(0);
}

/* Perbaikan overlay agar serasi dengan mobile 3 baris */
.photo-card photo-view-cols3 img {
    transition-delay: 0s !important;
}

.photo-card .info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    padding: 24px 12px 10px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    transform: translateY(0);
    transition: transform 0.2s;
}

.filename-text {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
}

.photo-card.selected {
    border-color: #10b981;
    transform: scale(0.96);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.photo-card.selected img {
    transform: scale(1.05);
    filter: brightness(0.9);
}

.photo-card.selected .info-overlay {
    background: linear-gradient(to top, rgba(30, 30, 45, 0.9) 0%, transparent 100%);
}

.check-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transform: scale(0.5) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 20;
    will-change: transform, opacity;
}

.photo-card.selected .check-badge {
    opacity: 1;
    transform: scale(1);
}

.number-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    z-index: 20;
    color: #1e1e2d;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-bar {
    background: #fff;
    border-top: 1px solid #ececf1;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
    z-index: 40;
}

.glass-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 40;
}

.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #ececf1;
}

.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.file-upload-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

.nav-tab {
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    color: #9ca3af;
    width: 100%;
}

.nav-tab i {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
}

.nav-tab.active {
    background-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    font-weight: 600;
}

.nav-tab:not(.active):hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 639px) {
    .action-bar {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    /* Tambahkan :not(.hidden) agar CSS ini tidak memaksa muncul jika sedang disembunyikan */
    .action-bar .controls:not(.hidden) {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .action-bar .controls button {
        flex: 1;
        justify-content: center;
    }

    body {
        height: 100dvh;
    }
}

/* Toggle Switch CSS */
.wrapper {
    display: flex;
    align-items: center;
    transform: scale(0.45);
    transform-origin: right center;
    margin-right: -8px;
}

#hide-checkbox {
    display: none;
}

.toggle {
    position: relative;
    width: 120px;
    height: 50px;
    background-color: #4facfe;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.toggle-button {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f7e06a;
    box-shadow: inset 0 -4px 0 #dcb53e, 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), background-color 0.4s, box-shadow 0.4s;
    overflow: hidden;
}

.crater {
    position: absolute;
    background-color: #e0e0e0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s;
    box-shadow: inset 0 2px 0 #c0c0c0;
}

.crater-1 {
    top: 10px;
    left: 8px;
    width: 8px;
    height: 8px;
}

.crater-2 {
    top: 20px;
    left: 20px;
    width: 12px;
    height: 12px;
}

.crater-3 {
    top: 8px;
    left: 24px;
    width: 6px;
    height: 6px;
}

.crater-4 {
    top: 26px;
    left: 8px;
    width: 5px;
    height: 5px;
}

.crater-5 {
    top: 28px;
    left: 30px;
    width: 4px;
    height: 4px;
}

.crater-6 {
    top: 16px;
    left: 32px;
    width: 4px;
    height: 4px;
}

.crater-7 {
    top: 24px;
    left: 3px;
    width: 3px;
    height: 3px;
}

.star {
    position: absolute;
    background-color: #ffffff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s, transform 0.4s;
    box-shadow: 0 0 4px #ffffff;
}

.star-1 {
    top: 12px;
    left: 30px;
    width: 3px;
    height: 3px;
}

.star-2 {
    top: 24px;
    left: 45px;
    width: 4px;
    height: 4px;
}

.star-3 {
    top: 38px;
    left: 25px;
    width: 2px;
    height: 2px;
}

.star-4 {
    top: 15px;
    left: 65px;
    width: 3px;
    height: 3px;
}

.star-5 {
    top: 32px;
    left: 80px;
    width: 4px;
    height: 4px;
}

.star-6 {
    top: 12px;
    left: 95px;
    width: 2px;
    height: 2px;
}

.star-7 {
    top: 26px;
    left: 105px;
    width: 3px;
    height: 3px;
}

.star-8 {
    top: 40px;
    left: 90px;
    width: 4px;
    height: 4px;
}

#hide-checkbox:checked+.toggle {
    background-color: #1e1e2d;
}

#hide-checkbox:checked+.toggle .toggle-button {
    transform: translateX(70px);
    background-color: #f5f5f5;
    box-shadow: inset 0 -4px 0 #e0e0e0, 0 2px 6px rgba(0, 0, 0, 0.2);
}

#hide-checkbox:checked+.toggle .toggle-button .crater {
    opacity: 1;
}

#hide-checkbox:checked+.toggle .star {
    opacity: 1;
    transform: translateY(-4px);
}

/* Dark Mode Overrides */
html.dark body {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

html.dark .bg-white {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark .bg-kama-50,
html.dark .bg-gray-50\/50 {
    background-color: #0f172a !important;
}

html.dark .text-kama-800 {
    color: #f8fafc !important;
}

html.dark .text-gray-500 {
    color: #94a3b8 !important;
}

html.dark .text-gray-600 {
    color: #cbd5e1 !important;
}

html.dark .text-gray-700 {
    color: #e2e8f0 !important;
}

html.dark .text-gray-400 {
    color: #64748b !important;
}

html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-kama-100 {
    border-color: #334155 !important;
}

html.dark .glass-header {
    background: rgba(30, 41, 59, 0.85) !important;
    border-bottom-color: #334155 !important;
}

html.dark .bg-gray-50 {
    background-color: #334155 !important;
}

html.dark .bg-gray-50\/60,
html.dark .bg-gray-50\/70,
html.dark .bg-gray-50\/80 {
    background-color: #334155 !important;
}

html.dark .bg-gray-100 {
    background-color: #475569 !important;
    border-color: #475569 !important;
}

html.dark .hover\:bg-gray-50:hover {
    background-color: #334155 !important;
}

html.dark .hover\:bg-gray-50\/80:hover {
    background-color: #334155 !important;
}

html.dark .hover\:bg-gray-100:hover {
    background-color: #475569 !important;
}

html.dark .hover\:bg-gray-200:hover {
    background-color: #64748b !important;
}

html.dark .hover\:bg-kama-50\/50:hover {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

html.dark .bg-kama-800 {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

html.dark .hover\:bg-kama-900:hover {
    background-color: #2563eb !important;
}

html.dark th {
    border-bottom-color: #334155 !important;
}

html.dark .shadow-\[0_2px_12px_rgb\(0\,0\,0\,0\.03\)\] {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

html.dark .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

html.dark .text-blue-700 {
    color: #93c5fd !important;
}

html.dark .hover\:bg-blue-100:hover {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

html.dark .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

html.dark .text-red-600 {
    color: #fca5a5 !important;
}

html.dark .hover\:bg-red-100:hover {
    background-color: rgba(239, 68, 68, 0.25) !important;
}

html.dark .divide-gray-50> :not([hidden])~ :not([hidden]) {
    border-color: #334155 !important;
}

/* Mata Icon Style */
.password-toggle-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #9ca3af;
}

.password-toggle-icon:hover {
    color: #4b5563;
}

html.dark .password-toggle-icon:hover {
    color: #cbd5e1;
}

/* ==========================================================================
   NON-BLOCKING TOAST NOTIFICATIONS (PHASE 5.6R ISSUE 1)
   ========================================================================== */
body.swal2-toast-shown .swal2-container,
.swal2-container.swal2-top,
.swal2-container.swal2-top-end,
.swal2-container.swal2-top-right,
.swal2-container:has(.swal2-toast) {
    background: transparent !important;
    pointer-events: none !important;
}

body.swal2-toast-shown .swal2-popup.swal2-toast,
.swal2-container .swal2-toast {
    pointer-events: auto !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--stroke, rgba(255, 255, 255, 0.15)) !important;
    backdrop-filter: blur(12px) !important;
}

/* Ensure SweetAlert2 modal is always above full-screen loaders (Task C) */
.swal2-container {
    z-index: 100000 !important;
}

