html, body {
    font-family: 'Inter', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
}

/* ── Disable native long-press callout / context menu on selectable cells ── */
.asset-select-container,
.album-card-container,
.album-list-item,
.memories-sheet-cell,
.folder-card-container,
.folder-list-item,
.map-drawer-cell,
.media-thumb-cell,
.asset-detail-content {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.asset-select-container img,
.album-card-container img,
.album-list-item img,
.memories-sheet-cell img,
.folder-card-container img,
.folder-list-item img,
.map-drawer-cell img,
.media-thumb-cell img {
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

/* ── Force selection checkbox icon to white in both light/dark themes ── */
.asset-select-checkbox .mud-icon-root,
.asset-select-checkbox svg,
.album-select-checkbox .mud-icon-root,
.album-select-checkbox svg,
.folder-select-checkbox .mud-icon-root,
.folder-select-checkbox svg,
.map-select-checkbox .mud-icon-root,
.map-select-checkbox svg {
    color: white !important;
    fill: white !important;
}

/* ── Timeline page: disable scroll on body/MudBlazor wrappers ── */
/* Must stay global — targets body and MudBlazor layout ancestors */
body.timeline-page {
    overflow: hidden !important;
    height: 100vh !important;
}
body.timeline-page .mud-layout {
    overflow: hidden !important;
    height: 100vh !important;
}
body.timeline-page .mud-main-content {
    overflow: hidden !important;
    height: 100vh !important;
    position: relative !important;
}

#app {
    height: 100%;
}

/* ── Typography overrides ────────────────────────────────── */
* {
    font-family: 'Inter', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.6;
}

/* Botones en minúscula (MudBlazor pone uppercase por defecto) */
.mud-button-label {
    text-transform: none;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.mud-text-h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

.mud-text-subtitle1 {
    font-weight: 500;
}

/* ── Page loading bar (fijo en el borde superior, encima del AppBar) ─ */
.page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    margin: 0 !important;
    height: 3px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.mud-button-root.mud-button-filled,
.mud-button-root.mud-button-outlined {
    padding: 10px 24px;
    min-height: 44px;
    font-size: 0.9375rem;
    border-radius: 22px !important;
}

.mud-icon-button {
    padding: 8px;
}

/* ── Asset cards ─────────────────────────────────────────── */
.asset-card {
    cursor: pointer;
    transition: box-shadow 0.2s;
    height: 100%;
}

.asset-card:hover {
    box-shadow: 0 4px 24px rgba(0,0,0,0.18) !important;
}

.asset-thumbnail {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
}

.asset-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Search field ────────────────────────────────────────── */
.search-field .mud-input-outlined-border {
    border: none !important;
    border-radius: 24px !important;
    background: var(--mud-palette-background-gray);
    transition: background 0.2s;
}

.search-field:focus-within .mud-input-outlined-border {
    border: 1.5px solid var(--mud-palette-primary) !important;
    background: var(--mud-palette-surface);
}

/* ── Album hero breadcrumb (siempre blanco sobre la imagen) ─ */
.album-hero-content .mud-breadcrumb-item a,
.album-hero-content .mud-breadcrumb-item span,
.album-hero-content .mud-breadcrumb-separator {
    color: rgba(255, 255, 255, 0.85) !important;
}

.album-hero-content .mud-breadcrumb-item a:hover {
    color: white !important;
}

/* ── Dialog actions con margen generoso ─────────────────── */
.mud-dialog-actions {
    padding: 12px 24px 20px !important;
    gap: 8px;
}

/* ── Nav active pill ─────────────────────────────────────── */
.mud-nav-link {
    border-radius: 8px !important;
    box-sizing: border-box;
}

.mud-drawer .mud-nav-menu {
    overflow-x: hidden;
    padding: 0 8px;
}

/* ── Blazor loading screen ───────────────────────────────── */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #FFD166;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: relative;
    text-align: center;
    font-weight: bold;
    top: -90px;
}

/* ── Blazor error bar ────────────────────────────────────── */
#blazor-error-ui {
    background: #1e1e2e;
    color: #e2e8f0;
    bottom: 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
}

#blazor-error-ui .dismiss:hover {
    opacity: 1;
}

/* ── Library card header: evita que la ruta larga empuje el menú fuera ── */
.library-card .mud-card-header-content {
    min-width: 0;
    overflow: hidden;
}

/* ── Page padding ─────────────────────────────────────── */
.page-pad {
    padding: 16px;
}
@media (min-width: 960px) {
    .page-pad {
        padding: 24px;
    }
}

/* ── Section header padding (admin/settings) ─────────── */
/* Push page content down to clear the mobile section-header bar.
   This must stay global because it targets elements outside the BottomNavBar component scope. */
@media (max-width: 959.98px) {
    body:has(.ph-section-header) .page-content {
        padding-top: 48px !important;
    }
}

/* ── Section tabs (Albums / Folders / Links) ───────────── */
.ph-section-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.ph-section-tabs::-webkit-scrollbar { display: none; }
.ph-section-tab {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    color: var(--mud-palette-text-secondary);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
    border: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
.ph-section-tab--active {
    color: var(--mud-palette-primary-text);
    background: var(--mud-palette-primary);
    font-weight: 600;
}

/* ── Photonne brand name – logo gold gradient ────────────── */
.ph-brand-name {
    background: linear-gradient(90deg, #ffffff 0%, #FFD166 55%, #E8A820 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Login layout background ─────────────────────────────── */
.login-layout {
    min-height: 100vh;
    background-image: url('/dark/bg-portrait.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.login-layout--light {
    background-image: url('/light/bg-portrait.png');
}

@media (orientation: landscape) {
    .login-layout {
        background-image: url('/dark/bg-landscape.png');
    }

    .login-layout--light {
        background-image: url('/light/bg-landscape.png');
    }
}

/* ── Mobile: márgenes en dialogs y bottom sheet ──────────── */
@media (max-width: 599px) {
    /* Margen lateral para todos los dialogs (evita que lleguen al borde) */
    .mud-dialog-container {
        padding: 0;
        box-sizing: border-box;
    }

    /* Bottom sheet: sin márgenes, pegado al fondo */
    .mud-dialog-container:has(.bottom-sheet-mobile) {
        padding: 0;
        align-items: flex-end;
    }
    .bottom-sheet-mobile {
        border-radius: 16px 16px 0 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
   Lightweight media thumb grid — shared between Albums, Folders and the
   Map cluster bottom sheet. Uses a CSS grid with auto-fill columns, inline
   <img> elements (no Blazor component overhead), native lazy loading and
   `content-visibility: auto` so off-screen cells skip layout/paint.

   Markup pattern:

       <div class="media-thumb-grid">
           <div class="media-thumb-cell" @key="..." @onclick="...">
               <img src="..." loading="lazy" decoding="async" />
               <div class="media-thumb-video-icon">▶</div>     // optional
               <div class="media-thumb-checkbox">…</div>       // optional
           </div>
       </div>
   ───────────────────────────────────────────────────────────────────────── */
.media-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 3px;
}

.media-thumb-cell {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    background: #333;
    /* Browser skips layout/paint when the cell is off-screen */
    content-visibility: auto;
    contain-intrinsic-size: 110px 110px;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.media-thumb-cell > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-thumb-cell.selected {
    transform: scale(0.90);
    background-color: var(--mud-palette-background-gray);
}

.media-thumb-cell.selection-mode:active {
    transform: scale(0.90);
    transition-duration: 0.06s;
}

/* Video play indicator */
.media-thumb-video-icon {
    position: absolute;
    bottom: 6px;
    right: 6px;
    color: white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    pointer-events: none;
    z-index: 2;
}

/* Selection checkbox overlay */
.media-thumb-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 999px;
    padding: 2px;
    color: white;
}

.media-thumb-checkbox .mud-icon-root {
    color: white !important;
}

.media-thumb-cell:hover .media-thumb-checkbox,
.media-thumb-cell.selected .media-thumb-checkbox {
    opacity: 1;
    pointer-events: auto;
}

/* Favorite toggle button: always visible bottom-right */
.media-thumb-favorite {
    position: absolute;
    bottom: 4px;
    right: 4px;
    z-index: 5;
    color: rgba(255, 255, 255, 0.7);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
    transition: color 0.2s;
}

.media-thumb-favorite:hover,
.media-thumb-favorite.is-favorite {
    color: white;
}

/* Broken image indicator (when the file is missing on disk) */
.media-thumb-broken {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.85);
    z-index: 3;
}

@media (max-width: 959.98px) {
    /* On touch devices the checkbox should only appear once an item is
       actually selected — long-press is what enters selection mode. */
    .media-thumb-cell:not(.selected):hover .media-thumb-checkbox {
        opacity: 0;
        pointer-events: none;
    }
}

.folder-view-toggle {
    gap: 8px;
    border: none !important;
    box-shadow: none !important;
}
.folder-view-toggle .mud-toggle-item {
    border-radius: 20px !important;
    background: var(--mud-palette-action-default-hover);
    flex: 1;
}
.folder-view-toggle .mud-toggle-item-selected {
    background: var(--mud-palette-primary) !important;
    color: var(--mud-palette-primary-text) !important;
}
