/* ===========================================================
   PHOTOS — Apple iOS Vibe + Vuexy
   Brand tím #7367F0 (đồng bộ POS pinhoanglong.vn)
   =========================================================== */

:root {
    --color-primary: #7367F0;
    --color-primary-700: #5d52d5;
    --color-primary-50: #f3f1ff;
    --color-bg: #F8F8FA;
    --color-surface: #ffffff;
    --color-text: #2d2d2d;
    --color-muted: #6b6b6b;
    --color-border: rgba(0, 0, 0, 0.06);

    --color-favorite: #ff3b30;
    --color-success: #34c759;
    --color-warn: #ff9500;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-pop:  0 8px 24px rgba(115, 103, 240, 0.18);
    --shadow-fab:  0 8px 24px rgba(115, 103, 240, 0.4);

    --header-h: 56px;
    --sidebar-w: 240px;

    --font-base: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* ===================== Layout shell ===================== */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}

.app-sidebar {
    grid-area: sidebar;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 18px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-primary);
}

.app-sidebar .logo .badge {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--color-primary-50);
    border-radius: var(--radius-md);
    font-size: 20px;
}

.app-sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-weight: 500;
    transition: background 0.12s ease;
}
.app-sidebar nav a:hover { background: var(--color-bg); text-decoration: none; }
.app-sidebar nav a.is-active {
    background: var(--color-primary-50);
    color: var(--color-primary);
}
.app-sidebar nav a svg { width: 20px; height: 20px; stroke-width: 1.75; }

.user-block {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
    display: flex; align-items: center; gap: 10px;
}
.user-block .avatar {
    width: 36px; height: 36px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 600;
}
.user-block .user-name { font-weight: 600; font-size: 13px; }
.user-block .user-meta { font-size: 11px; color: var(--color-muted); }
.user-block button {
    background: none; border: none; color: var(--color-muted);
    cursor: pointer; padding: 6px; border-radius: 6px;
    margin-left: auto;
}
.user-block button:hover { background: var(--color-bg); color: var(--color-text); }

.app-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-topbar h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.app-topbar .spacer { flex: 1; }

.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--color-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 6px 12px;
    min-width: 280px;
}
.search-box:focus-within {
    background: white;
    border-color: var(--color-primary);
}
.search-box input {
    border: none; outline: none; background: transparent;
    font-size: 14px; flex: 1;
}
.search-box svg { width: 18px; height: 18px; color: var(--color-muted); stroke-width: 1.75; }

.app-main {
    grid-area: main;
    padding: 24px 28px 80px;
    overflow-x: hidden;
}

/* ===================== Buttons ===================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--color-primary);
    color: white;
}
.btn-primary:hover { background: var(--color-primary-700); }

.btn-ghost {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); }

.btn-danger {
    background: rgba(255,59,48,0.1);
    color: var(--color-favorite);
}
.btn-danger:hover { background: rgba(255,59,48,0.18); }

/* ===================== Cards / Stats ===================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
}
.stat-card .label { font-size: 13px; color: var(--color-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-card .delta { font-size: 12px; color: var(--color-muted); margin-top: 4px; }

.section-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}
.section-card h2 {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 700;
}

.storage-bar {
    height: 8px; background: var(--color-bg); border-radius: 4px;
    overflow: hidden; margin-top: 6px;
}
.storage-bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #b3a8ff);
    transition: width 0.4s ease;
}
.storage-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--color-muted); margin-top: 6px; }

/* ===================== Photo grid ===================== */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px;
}

.photo-card {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    background: #eee;
    position: relative;
}
.photo-card:hover {
    transform: scale(1.02);
    z-index: 1;
    box-shadow: var(--shadow-pop);
}
.photo-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}

.photo-card .badge-video {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}
.photo-card .badge-fav {
    position: absolute; bottom: 6px; left: 6px;
    color: var(--color-favorite);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.photo-card .placeholder {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    color: #b8b8b8;
}

.month-header {
    position: sticky;
    top: var(--header-h);
    background: rgba(248, 248, 250, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 14px 6px;
    font-weight: 600;
    font-size: 1.05rem;
    z-index: 10;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    margin: 24px 0 8px;
}
.month-header:first-of-type { margin-top: 0; }

/* ===================== FAB upload ===================== */

.fab-upload {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-fab);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 100;
    text-decoration: none;
}
.fab-upload:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 32px rgba(115, 103, 240, 0.5);
    text-decoration: none;
}
.fab-upload svg { width: 26px; height: 26px; stroke-width: 1.75; }

/* ===================== Photo modal ===================== */

.photo-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.photo-modal__close {
    position: absolute; top: 16px; right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    color: white;
    display: grid; place-items: center;
    cursor: pointer;
}
.photo-modal__close:hover { background: rgba(255,255,255,0.25); }
.photo-modal img {
    max-width: 92vw;
    max-height: 86vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.photo-modal__nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    color: white;
    border: none;
    width: 48px; height: 48px;
    border-radius: 50%;
    display: grid; place-items: center;
    cursor: pointer;
}
.photo-modal__nav:hover { background: rgba(255,255,255,0.2); }
.photo-modal__nav.prev { left: 24px; }
.photo-modal__nav.next { right: 24px; }
.photo-modal__actions {
    position: absolute; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 12px;
    background: rgba(0,0,0,0.6);
    border-radius: 999px;
    padding: 8px 12px;
    backdrop-filter: blur(10px);
}
.photo-modal__actions button {
    background: none; border: none;
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background 0.12s;
}
.photo-modal__actions button:hover { background: rgba(255,255,255,0.15); }
.photo-modal__actions button.is-fav { color: var(--color-favorite); }

/* ===================== Login / Register ===================== */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 20%, #efedff 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, #fff 0%, transparent 50%),
        linear-gradient(135deg, #f6f4ff 0%, #ffffff 100%);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: 0 12px 36px rgba(115, 103, 240, 0.12);
    border: 1px solid rgba(115, 103, 240, 0.08);
}
.auth-card .logo {
    display: flex; align-items: center; gap: 10px;
    justify-content: center;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 4px;
}
.auth-card .subtitle {
    text-align: center;
    color: var(--color-muted);
    font-size: 13px;
    margin-bottom: 24px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(115, 103, 240, 0.15);
}
.btn-block { width: 100%; justify-content: center; }
.form-meta {
    display: flex; justify-content: space-between;
    font-size: 13px; color: var(--color-muted);
    margin-top: 16px;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: rgba(255, 59, 48, 0.08); color: #c00; }
.alert-success { background: rgba(52, 199, 89, 0.1); color: #1f7a3a; }

/* ===================== Upload zone ===================== */

.dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
    background: white;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.dropzone.is-dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
}
.dropzone svg {
    width: 56px; height: 56px;
    color: var(--color-primary);
    stroke-width: 1.5;
    margin-bottom: 12px;
}
.dropzone h3 { margin: 0 0 6px; font-size: 1.1rem; }
.dropzone p { margin: 0; color: var(--color-muted); font-size: 14px; }

.upload-list { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.upload-item {
    background: white;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    box-shadow: var(--shadow-card);
}
.upload-item .name { font-size: 13px; font-weight: 600; truncate: true; }
.upload-item .meta { font-size: 11px; color: var(--color-muted); }
.upload-item .progress {
    grid-column: 1 / -1;
    height: 4px; background: var(--color-bg);
    border-radius: 2px; overflow: hidden;
}
.upload-item .progress > span {
    display: block; height: 100%;
    background: var(--color-primary);
    transition: width 0.2s ease;
}
.upload-item.is-done .progress > span { background: var(--color-success); }
.upload-item.is-error .progress > span { background: var(--color-favorite); }
.upload-item .status { font-size: 12px; }

/* ===================== Misc ===================== */

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--color-muted);
}
.empty-state svg {
    width: 64px; height: 64px;
    color: #d8d8d8;
    stroke-width: 1.5;
    margin-bottom: 16px;
}
.empty-state h3 { color: var(--color-text); margin: 0 0 6px; }
.empty-state p { margin: 0; font-size: 14px; }

.flash-toast {
    position: fixed;
    top: 76px;
    right: 24px;
    background: rgba(40, 40, 40, 0.95);
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    font-size: 13px;
    z-index: 200;
}

/* Responsive */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
    .app-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 200;
        transition: left 0.2s;
        width: 80%;
    }
    .app-sidebar.is-open { left: 0; }
    .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 2px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .search-box { min-width: 0; flex: 1; }
}
