/* ============================================================
   Photobook — estilos principales
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --header-h   : 56px;
    --sidebar-w  : 200px;
    --blue       : #1a73e8;
    --blue-hover : #1557b0;
    --text       : #202124;
    --text2      : #5f6368;
    --border     : #e0e0e0;
    --hover-bg   : #f1f3f4;
    --radius     : 4px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: #fff; color: var(--text); }

/* Accesibilidad — texto solo para lectores de pantalla */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ── Botones de icono ── */
.icon-btn {
    background: none; border: none; cursor: pointer;
    color: inherit; padding: 8px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 0;
}
.icon-btn:hover { background: rgba(0,0,0,0.06); }
.icon-btn svg   { pointer-events: none; }

/* ── LOGIN ── */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #f8f9fa;
}
.login-box {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 40px 36px; width: 320px; text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.login-icon { margin-bottom: 12px; }
.login-box h1 { font-size: 20px; font-weight: 400; margin-bottom: 24px; color: var(--text); }
.login-box input[type=password], .login-box input[type=email] {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 15px; outline: none; color: var(--text);
}
.login-box input[type=password]:focus, .login-box input[type=email]:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
.login-box input[type=email] { margin-bottom: 10px; }
.login-box button[type=submit] {
    margin-top: 14px; width: 100%; padding: 11px;
    background: var(--blue); color: #fff; border: none; border-radius: var(--radius);
    font-size: 15px; cursor: pointer;
}
.login-box button[type=submit]:hover { background: var(--blue-hover); }
.login-error {
    background: #fce8e6; color: #c5221f; padding: 9px 14px;
    border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
}

/* ── CABECERA ── */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
    background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 8px 0 4px; z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.header-left  { display: flex; align-items: center; gap: 4px; }
.app-title    { font-size: 20px; font-weight: 400; color: var(--text); padding-left: 4px; }
.header-right { display: flex; align-items: center; gap: 16px; }
#stats-label  { font-size: 13px; color: var(--text2); }
.stats-button { border: 0; background: transparent; color: var(--text2); font-size: 13px; cursor: pointer; padding: 5px; }
.stats-button:hover { color: var(--blue); }
.logout-link  { font-size: 14px; color: var(--blue); text-decoration: none; padding: 4px 8px; }
.logout-link:hover { text-decoration: underline; }
.menu-btn     { color: var(--text2); }

/* ── LAYOUT ── */
.app-body {
    display: flex;
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h));
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    border-right: 1px solid var(--border);
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    overflow-y: auto; background: #fff; z-index: 50;
    transition: transform 0.2s ease;
}
.sidebar-header {
    font-size: 11px; font-weight: 600; color: var(--text2);
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 16px 16px 8px;
}
.sidebar-header-row { display: flex; align-items: center; justify-content: space-between; }
.small-icon-btn { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 20px; line-height: 1; padding: 0 5px; }
.year-group { margin-bottom: 4px; }
.year-label {
    font-size: 13px; font-weight: 600; color: var(--text);
    padding: 6px 16px; cursor: pointer; display: flex;
    align-items: center; justify-content: space-between;
    user-select: none;
}
.year-label:hover { background: var(--hover-bg); }
.month-item {
    font-size: 13px; color: var(--text2);
    padding: 5px 16px 5px 28px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
}
.month-item:hover  { background: var(--hover-bg); color: var(--text); }
.month-item.active { color: var(--blue); font-weight: 500; }
.month-count { font-size: 12px; color: var(--text2); }
.sidebar-action {
    width: 100%; border: none; background: transparent; color: var(--text2);
    cursor: pointer; display: flex; justify-content: space-between; text-align: left;
    padding: 7px 16px; font-size: 13px;
}
.sidebar-action:hover, .sidebar-action.active { background: var(--hover-bg); color: var(--blue); }

/* ── GALERÍA ── */
.gallery-wrap {
    flex: 1; margin-left: var(--sidebar-w);
    padding: 16px 12px; min-width: 0;
}
.date-section { margin-bottom: 24px; }
.date-header  { font-size: 15px; font-weight: 500; padding: 6px 4px 10px; }
.photo-row    { display: flex; gap: 4px; margin-bottom: 4px; align-items: flex-start; }

.photo-item {
    flex-shrink: 0; overflow: hidden; cursor: pointer;
    background: #e8eaed; position: relative; display: block;
    border-radius: 2px;
}
.photo-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.15s; }
.photo-item:hover img { opacity: 0.82; }

/* Badge vídeo */
.photo-item.is-video::after {
    content: '';
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 0; height: 0;
    border: solid transparent;
    border-width: 15px 0 15px 26px;
    border-left-color: rgba(255,255,255,0.88);
    pointer-events: none;
}
.vid-label {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.55); color: #fff;
    font-size: 11px; padding: 2px 6px; border-radius: 10px;
    pointer-events: none;
}
.favorite-badge { position: absolute; top: 6px; left: 6px; background: rgba(198, 40, 40, 0.88); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 10px; pointer-events: none; }

/* Zona inferior */
#footer-zone { text-align: center; padding: 24px; }
#btn-load-more {
    padding: 10px 32px; background: var(--blue); color: #fff;
    border: none; border-radius: var(--radius); font-size: 14px; cursor: pointer;
}
#btn-load-more:hover { background: var(--blue-hover); }
#msg-end { color: var(--text2); font-size: 14px; }

.gallery-loading { text-align: center; padding: 60px; color: var(--text2); font-size: 15px; }

/* ── LIGHTBOX ── */
dialog#lightbox {
    position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
    background: transparent; border: none; padding: 0; margin: 0;
    display: none; flex-direction: column; z-index: 200;
}
dialog#lightbox[open] { display: flex; }

.lb-bg {
    position: absolute; inset: 0; background: rgba(0,0,0,0.94);
    border: none; cursor: default; width: 100%; height: 100%;
    z-index: 0;
}

.lb-topbar {
    position: relative; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 8px 8px 16px; color: #fff;
    background: rgba(0,0,0,.25);
}
#lb-date    { font-size: 14px; color: rgba(255,255,255,.85); }
.lb-controls { display: flex; align-items: center; gap: 2px; }
.lb-controls .icon-btn { color: #fff; }
.lb-controls .icon-btn:hover { background: rgba(255,255,255,.12); }
.lb-controls a.icon-btn { color: #fff; text-decoration: none; }

.lb-media {
    position: relative; z-index: 10;
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 12px 64px; overflow: hidden;
}
.lb-media img   { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-media video { max-width: 100%; max-height: 100%; outline: none; }

.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
    background: rgba(255,255,255,0.1); border: none; color: #fff;
    font-size: 42px; line-height: 1; padding: 14px 6px;
    cursor: pointer; border-radius: var(--radius);
    transition: background 0.15s;
}
.lb-nav:hover  { background: rgba(255,255,255,0.2); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }

/* ── MODAL COMPARTIR ── */
dialog#share-modal {
    position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
    background: transparent; border: none; padding: 0; margin: 0;
    display: none; align-items: center; justify-content: center; z-index: 300;
}
dialog#share-modal[open] { display: flex; }

.modal-bg {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.45); border: none; cursor: default;
    width: 100%; height: 100%;
}
.modal-box {
    position: relative; z-index: 10;
    background: #fff; border-radius: 8px; padding: 24px;
    width: min(460px, 90vw);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-box h3 { font-size: 18px; font-weight: 500; margin-bottom: 10px; }
.modal-box p  { font-size: 14px; color: var(--text2); margin-bottom: 12px; }
.share-row { display: flex; gap: 8px; }
.share-row input {
    flex: 1; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13px; color: var(--text);
    background: #f8f9fa;
}
.share-row button, .modal-footer button {
    padding: 8px 18px; background: var(--blue); color: #fff;
    border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.modal-label { display: block; color: var(--text2); font-size: 13px; margin: 10px 0 5px; }
#share-expiry, .album-create input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: #fff; padding: 8px 10px; font-size: 14px; }
.file-picker { display: block; padding: 24px 12px; border: 1px dashed #9aa0a6; border-radius: var(--radius); color: var(--blue); text-align: center; cursor: pointer; margin: 12px 0 8px; }
#upload-files { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.modal-note { color: var(--text2); font-size: 13px; line-height: 1.45; margin-top: 10px; }
.album-choice { width: 100%; border: 0; background: transparent; color: var(--text); padding: 9px 2px; display: flex; justify-content: space-between; cursor: pointer; text-align: left; }
.album-choice:hover { color: var(--blue); background: var(--hover-bg); }
.album-choice span { color: var(--text2); font-size: 12px; }
.album-create { display: flex; gap: 8px; margin-top: 12px; }
.album-create button { padding: 8px 16px; border: 0; border-radius: var(--radius); background: var(--blue); color: #fff; cursor: pointer; }
.is-favorite { color: #f28b82 !important; }
.status-list { margin-top: 12px; }
.status-list div { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.status-list dt { color: var(--text2); }
.status-list dd { margin: 0; color: var(--text); font-weight: 500; text-align: right; }
.share-row button:hover, .modal-footer button:hover { background: var(--blue-hover); }
#share-copied { display: none; font-size: 13px; color: #188038; margin-top: 8px; }
.modal-footer { text-align: right; margin-top: 16px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 16px rgba(0,0,0,.15); }
    .gallery-wrap { margin-left: 0; }
    .lb-media { padding: 12px 48px; }
}
@media (max-width: 480px) {
    .lb-media { padding: 8px 40px; }
    .lb-nav { font-size: 32px; padding: 10px 4px; }
}
