/* ===================================
   mobile.css - Mobile Adaptive View
   =================================== */

/* ── Hide desktop UI when mobile view is active ── */
body.mobile-view .login-header,
body.mobile-view #container,
body.mobile-view .toolbar,
body.mobile-view .zoom-info,
body.mobile-view .shortcuts-modal,
body.mobile-view .drawing-controls,
body.mobile-view .context-menu,
body.mobile-view #guestGate {
    display: none !important;
}

body.mobile-view {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ── Mobile View Container ── */
.mobile-view-container {
    display: none;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    background: #f8f7f4;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.mobile-view .mobile-view-container {
    display: flex;
}

/* ── Mobile Header ── */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: #fff;
    border-bottom: 1px solid #e8e5df;
    flex-shrink: 0;
    min-height: 48px;
}

.mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    color: #2d2a26;
}

.mobile-header-brand svg {
    flex-shrink: 0;
}

.mobile-tree-name {
    font-size: 13px;
    color: #8b8680;
    font-weight: 400;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mobile-desktop-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #d4d0ca;
    background: #fff;
    color: #5d5a55;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}

.mobile-desktop-btn:active {
    background: #f0ede8;
}

/* ── Tab Content ── */
.mobile-tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}

.mobile-tab-pane {
    display: none;
    min-height: 100%;
}

.mobile-tab-pane.active {
    display: block;
}

/* ── Bottom Tab Bar ── */
.mobile-tab-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #fff;
    border-top: 1px solid #e8e5df;
    flex-shrink: 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    height: 56px;
    position: relative;
    z-index: 10;
}

.mobile-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: 6px 0;
    border: none;
    background: none;
    color: #a09b94;
    cursor: pointer;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-tab-btn svg {
    transition: color 0.2s;
}

.mobile-tab-btn.active {
    color: #4a7c3f;
}

.mobile-tab-btn.active svg {
    stroke: #4a7c3f;
}

/* ═══════════════════════════════════
   TREE VIEW
   ═══════════════════════════════════ */

.mtree-container {
    padding: 16px;
}

.mtree-root {
    position: relative;
}

.mtree-node {
    position: relative;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 4px;
    border: 1px solid #e8e5df;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mtree-node:active {
    background: #f5f3ef;
}

.mtree-node-name {
    font-weight: 600;
    font-size: 14px;
    color: #2d2a26;
}

.mtree-node-dates {
    font-size: 12px;
    color: #8b8680;
    margin-top: 2px;
}

.mtree-node-spouse {
    font-size: 11px;
    color: #a09b94;
    margin-top: 1px;
}

.mtree-node-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.08);
}

.mtree-node-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mtree-node-info {
    flex: 1;
    min-width: 0;
}

.mtree-node-gen {
    font-size: 10px;
    color: #b5b0a8;
    font-weight: 500;
}

/* Tree connector lines */
.mtree-children {
    position: relative;
    margin-left: 20px;
    padding-left: 16px;
}

.mtree-children::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 12px;
    width: 2px;
    background: #d4d0ca;
    border-radius: 1px;
}

.mtree-children > .mtree-branch::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 20px;
    width: 14px;
    height: 2px;
    background: #d4d0ca;
}

.mtree-branch {
    position: relative;
}

/* ═══════════════════════════════════
   PEOPLE VIEW
   ═══════════════════════════════════ */

.mobile-gen-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8f7f4;
    padding: 12px 16px 6px;
    font-size: 13px;
    font-weight: 600;
    color: #5d5a55;
    border-bottom: 1px solid #e8e5df;
}

.mobile-gen-count {
    font-weight: 400;
    color: #a09b94;
    margin-left: 6px;
}

.mobile-people-list {
    padding: 0 16px;
}

.mobile-person-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0ede8;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-person-card:active {
    opacity: 0.7;
}

.mobile-person-card:last-child {
    border-bottom: none;
}

.mobile-person-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e8e5df;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
}

.mobile-person-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-person-avatar .avatar-initials {
    font-size: 16px;
    font-weight: 600;
    color: #8b8680;
}

.mobile-person-info {
    flex: 1;
    min-width: 0;
}

.mobile-person-name {
    font-weight: 600;
    font-size: 15px;
    color: #2d2a26;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-person-dates {
    font-size: 13px;
    color: #8b8680;
    margin-top: 2px;
}

.mobile-person-spouse {
    font-size: 12px;
    color: #a09b94;
    margin-top: 1px;
}

.mobile-person-photos-count {
    font-size: 11px;
    color: #4a7c3f;
    font-weight: 500;
    margin-top: 2px;
}

.mobile-person-chevron {
    color: #c8c4bc;
    flex-shrink: 0;
}

/* ═══════════════════════════════════
   PHOTOS VIEW
   ═══════════════════════════════════ */

.mobile-photos-container {
    padding: 16px;
}

.mobile-photos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mobile-photos-title {
    font-size: 15px;
    font-weight: 600;
    color: #2d2a26;
}

.mobile-upload-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: #4a7c3f;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-upload-btn:active {
    opacity: 0.85;
}

.mobile-photo-section {
    margin-bottom: 20px;
}

.mobile-photo-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #8b8680;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.mobile-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.mobile-photo-tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-photo-tile:active {
    opacity: 0.85;
}

.mobile-photo-tile .photo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-photos-empty {
    text-align: center;
    padding: 48px 20px;
    color: #a09b94;
}

.mobile-photos-empty svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.mobile-photos-empty p {
    font-size: 14px;
    margin: 0;
}

/* ═══════════════════════════════════
   BOTTOM SHEET
   ═══════════════════════════════════ */

.mobile-sheet-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2100;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-sheet-overlay.show {
    display: block;
    opacity: 1;
}

.mobile-bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    z-index: 2200;
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.mobile-bottom-sheet.show {
    transform: translateY(0);
}

.mobile-sheet-handle {
    width: 36px;
    height: 4px;
    background: #d4d0ca;
    border-radius: 2px;
    margin: 10px auto 0;
}

.mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
}

.mobile-sheet-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d2a26;
}

.mobile-sheet-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0ede8;
    color: #5d5a55;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.mobile-sheet-body {
    padding: 0 20px 16px;
}

/* Person detail sheet */
.mobile-person-detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 12px;
    display: block;
    background: #e8e5df;
    border: 2px solid rgba(0,0,0,0.06);
}

.mobile-detail-name {
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    color: #2d2a26;
    margin-bottom: 4px;
}

.mobile-detail-dates {
    text-align: center;
    font-size: 14px;
    color: #8b8680;
    margin-bottom: 16px;
}

.mobile-detail-section {
    margin-bottom: 16px;
}

.mobile-detail-label {
    font-size: 12px;
    font-weight: 600;
    color: #a09b94;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.mobile-detail-value {
    font-size: 14px;
    color: #2d2a26;
    line-height: 1.5;
}

.mobile-detail-photos {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mobile-detail-photo {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
}

.mobile-sheet-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
}

.mobile-sheet-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-sheet-btn-primary {
    background: #4a7c3f;
    color: #fff;
}

.mobile-sheet-btn-primary:active {
    opacity: 0.85;
}

.mobile-sheet-btn-secondary {
    background: #f0ede8;
    color: #5d5a55;
}

.mobile-sheet-btn-secondary:active {
    background: #e4e0d9;
}

/* Photo detail sheet */
.mobile-photo-detail-img {
    width: 100%;
    max-height: 50dvh;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 16px;
    background: #f0ede8;
}

.mobile-assign-list {
    max-height: 40dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-assign-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0ede8;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-assign-item:active {
    opacity: 0.7;
}

.mobile-assign-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e8e5df;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.mobile-assign-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-assign-avatar .avatar-initials {
    font-size: 13px;
    font-weight: 600;
    color: #8b8680;
}

.mobile-assign-name {
    font-size: 14px;
    font-weight: 500;
    color: #2d2a26;
}

/* Add from gallery / upload buttons in person sheet */
.mobile-add-gallery-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #d4d0ca;
    background: #fff;
    color: #4a7c3f;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-add-gallery-btn:active {
    background: #f0ede8;
}

/* Photo action buttons on tiles */
.mobile-photo-tile .photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mobile-photo-tile:hover .photo-remove,
.mobile-photo-tile:active .photo-remove {
    display: flex;
}
