/* CARTERA - Main Stylesheet */
/* Inspired by existing CARTERA dark theme + 1Password/SafeInCloud */

:root {
    --bg: #000000;
    --bg2: #0a0a0a;
    --bg3: #111111;
    --bg4: #1a1a1a;
    --card-bg: #141414;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text2: #999999;
    --text3: #666666;
    --accent: #c9a84c;
    --accent2: #e8c875;
    --accent-bg: rgba(201,168,76,0.1);
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --info: #3498db;
    --modal-bg: rgba(0,0,0,0.85);
    --glass: rgba(20,20,20,0.95);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'DM Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
    --bg: #f4f5f7;
    --bg2: #ffffff;
    --bg3: #f7f8fa;
    --bg4: #eceef2;
    --card-bg: #ffffff;
    --border: #e2e5ea;
    --text: #1a1c1f;
    --text2: #5a6270;
    --text3: #8c94a3;
    --accent-bg: rgba(201,168,76,0.14);
    --modal-bg: rgba(20,22,28,0.45);
    --glass: rgba(255,255,255,0.98);
    --shadow: 0 2px 8px rgba(17,24,39,0.08), 0 1px 3px rgba(17,24,39,0.06);
}

[data-theme="light"] body { background: var(--bg); }

[data-theme="light"] .card-item,
[data-theme="light"] .stat-card,
[data-theme="light"] .auth-box {
    box-shadow: 0 1px 3px rgba(17,24,39,0.06), 0 1px 2px rgba(17,24,39,0.04);
}

[data-theme="light"] .card-item:hover {
    box-shadow: 0 4px 12px rgba(17,24,39,0.10), 0 2px 4px rgba(17,24,39,0.06);
}

[data-theme="light"] .modal {
    box-shadow: 0 20px 60px rgba(17,24,39,0.25), 0 8px 20px rgba(17,24,39,0.15);
}

[data-theme="light"] .sidebar-overlay { background: rgba(17,24,39,0.4); }

[data-theme="light"] .scan-overlay { background: rgba(255,255,255,0.88); }

[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d0d4dc; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #aeb4bf; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ========== APP LAYOUT ========== */
#app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    transition: grid-template-columns var(--transition);
}

#app.no-sidebar { grid-template-columns: 0 1fr; }
#app.no-sidebar #sidebar { display: none; }

/* ========== SIDEBAR ========== */
#sidebar {
    grid-column: 1;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    /* 100vh is wrong on iOS Safari — it ignores the URL bar. 100dvh
       (dynamic viewport height) respects the actually-visible area so the
       sidebar footer buttons stop getting hidden behind the URL bar. */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* PWA install banner */
.pwa-install-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    background: var(--bg2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    max-width: calc(100% - 32px);
    animation: pwaBannerIn 0.3s ease;
}
@keyframes pwaBannerIn {
    from { transform: translate(-50%, 30px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
.pwa-install-banner.hidden { display: none; }
.pwa-install-banner .pwa-install-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.pwa-install-banner .pwa-install-text strong { font-size: 13px; color: var(--accent); }
.pwa-install-banner .pwa-install-text span {
    font-size: 11px;
    color: var(--text2);
    line-height: 1.35;
    margin-top: 2px;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
    font-size: 18px;
    letter-spacing: 6px;
    color: var(--accent);
    font-weight: 700;
}

.sidebar-logo small {
    font-size: 9px;
    color: var(--text3);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.sidebar-logo img#sidebar-logo-img {
    display: block;
    max-width: 100%;
    max-height: 56px;
    margin: 0 auto;
    object-fit: contain;
}

.sidebar-logo img#sidebar-logo-img.hidden {
    display: none;
}

/* Admin Switcher */
.admin-switcher {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.admin-switcher:hover { background: var(--bg3); }

.admin-switcher .admin-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.admin-switcher .admin-company {
    font-size: 11px;
    color: var(--text2);
}

.admin-switcher .switch-icon {
    float: right;
    color: var(--text3);
    font-size: 12px;
}

/* Nav */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0; /* allow flex shrink so footer stays visible */
    overflow-y: auto;
    padding: 8px 0;
}

.nav-section {
    padding: 8px 16px 4px;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text3);
    text-transform: uppercase;
    font-weight: 600;
}

.nav-section-items { overflow: hidden; transition: max-height 0.3s ease; }
.nav-section-items.collapsed { max-height: 0 !important; }
.nav-section .collapsed-arrow { transition: transform 0.2s; display: inline-block; }
.nav-section.collapsed .collapsed-arrow { transform: rotate(-90deg); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-bg); }

.nav-item .icon { width: 20px; text-align: center; font-size: 15px; }
.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: #000;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* Sidebar footer */
.sidebar-footer {
    /* Account for iOS home indicator — extra bottom padding on devices
       that expose safe-area-inset-bottom so the buttons don't get covered. */
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg2);
}

.sidebar-footer button {
    flex: 1;
    padding: 8px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text2);
    cursor: pointer;
    font-size: 12px;
    transition: all var(--transition);
}

.sidebar-footer button:hover { background: var(--bg4); color: var(--text); }

/* ========== MAIN CONTENT ========== */
#main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
    flex-shrink: 0;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}

.search-box input:focus { border-color: var(--accent); }

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 14px;
}

.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* View Mode Buttons */
.view-modes { display: flex; gap: 2px; }
.view-mode-btn {
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}

.view-mode-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.view-mode-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.view-mode-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* Content Area */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg4); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; }
.btn-icon:hover { color: var(--accent); }

/* ========== CARDS GRID ========== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.card-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
}

.card-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

.card-visual {
    padding: 20px;
    background: linear-gradient(135deg, var(--c1, #1a6fb5), var(--c2, #0d4a7a));
    color: #fff;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.card-visual .card-type {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-visual .card-holder {
    font-size: 11px;
    letter-spacing: 1px;
    opacity: 0.8;
    text-transform: uppercase;
}

.card-visual .card-title {
    font-size: 15px;
    font-weight: 600;
    margin-top: 4px;
}

.card-visual .card-number {
    font-family: var(--mono);
    font-size: 16px;
    letter-spacing: 3px;
    margin-top: auto;
    padding-top: 16px;
}

.card-visual .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 8px;
}

.card-visual .card-expiry {
    font-size: 11px;
    opacity: 0.8;
}

.card-meta {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-meta .card-cat {
    font-size: 11px;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-meta .card-fav {
    font-size: 16px;
    cursor: pointer;
    color: var(--text3);
    transition: color var(--transition);
}

.card-meta .card-fav.active { color: var(--accent); }

/* ========== LIST VIEW ========== */
.list-view .card-item {
    display: flex;
    align-items: center;
    min-height: auto;
}

.list-view .card-visual {
    min-height: auto;
    width: 200px;
    flex-shrink: 0;
    padding: 12px 16px;
}

.list-view .card-meta {
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

/* ========== TABLE VIEW ========== */
.table-view { width: 100%; }
.table-view table { width: 100%; border-collapse: collapse; }
.table-view th, .table-view td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.table-view th { color: var(--text3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.table-view tr:hover { background: var(--bg3); }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 18px; font-weight: 600; }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 20px;
    border-radius: 50%;
    transition: all var(--transition);
}

.modal-close:hover { background: var(--bg3); color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.form-control:focus { border-color: var(--accent); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* Toggle switch */
.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle input { display: none; }
.toggle span {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    transition: background var(--transition);
}

.toggle span::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
}

.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }

/* ========== LOGIN SCREEN ========== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.auth-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.auth-box .logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-box .logo h1 {
    font-size: 28px;
    letter-spacing: 8px;
    color: var(--accent);
}

.auth-box .logo p {
    font-size: 11px;
    color: var(--text3);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--text3);
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #fff;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== EMERGENCY KIT BANNER ========== */
.ek-banner {
    background: var(--warning);
    color: #000;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
}

.ek-banner button {
    margin-left: auto;
    padding: 6px 12px;
    background: rgba(0,0,0,0.2);
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
}

/* ========== PASSWORD STRENGTH ========== */
.pw-strength {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin-top: 6px;
    overflow: hidden;
}

.pw-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
}

.pw-strength-bar.weak { width: 25%; background: var(--danger); }
.pw-strength-bar.fair { width: 50%; background: var(--warning); }
.pw-strength-bar.good { width: 75%; background: var(--info); }
.pw-strength-bar.strong { width: 100%; background: var(--success); }

/* ========== DASHBOARD ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card .stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ========== TOTP ========== */
.totp-code {
    font-family: var(--mono);
    font-size: 32px;
    letter-spacing: 6px;
    color: var(--accent);
    text-align: center;
    padding: 16px;
}

.totp-countdown {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

/* ========== PASSWORD GENERATOR ========== */
.pw-output {
    font-family: var(--mono);
    font-size: 18px;
    padding: 16px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    letter-spacing: 2px;
    word-break: break-all;
    margin-bottom: 16px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    #app { grid-template-columns: 1fr; }
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 300px;
        z-index: 999;
        transition: left 0.3s ease;
    }
    #sidebar.open { left: 0; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 998;
        display: none !important;
    }
    .sidebar-overlay.active { display: block !important; }
    .cards-grid { grid-template-columns: 1fr; gap: 12px; }
    .content { padding: 16px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: 15px; }
    .search-box { flex: 1; min-width: 0; max-width: none; }
    .auth-box { margin: 16px; padding: 24px; }
    .form-row { flex-direction: column; gap: 0; }
    .modal { width: 92%; max-width: 92%; max-height: 88vh; display: flex; flex-direction: column; }
    .modal-body { overflow-y: auto; flex: 1; }
    .modal-header, .modal-footer { flex-shrink: 0; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 24px; }
    .view-modes { display: none; }
}

@media (max-width: 480px) {
    .modal { width: 95% !important; max-width: 95% !important; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px 18px; }
    .modal-footer { padding: 12px 18px; }
    .form-row { flex-direction: column; gap: 0; }
    .topbar { padding: 0 12px; gap: 6px; }
    .search-box { flex: 1; min-width: 0; }
    .view-modes { display: none; }
    .topbar-title { font-size: 14px; }
    .cards-grid { grid-template-columns: 1fr; gap: 12px; }
    h2, h3 { font-size: 16px !important; }
    .btn { font-size: 12px; padding: 6px 12px; }
    .btn-lg { font-size: 13px; padding: 10px 16px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 22px; }
    .stat-card .stat-icon { font-size: 20px; }
    .content { padding: 12px; }
    .admin-switcher { padding: 10px 12px; }
    .admin-switcher .admin-name { font-size: 12px; }
    .admin-switcher .admin-company { font-size: 10px; }
    .auth-box { padding: 20px; margin: 12px; }
    .auth-box .logo h1 { font-size: 22px; letter-spacing: 5px; }
    .totp-code { font-size: 26px; letter-spacing: 4px; padding: 12px; }
    .pin-input input { width: 42px; height: 50px; font-size: 20px; }
    .list-view .card-visual { width: 140px; }
}

/* ========== LOCK SCREEN ========== */
.lock-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.lock-box {
    text-align: center;
}

.lock-box .lock-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.lock-box h2 {
    margin-bottom: 24px;
    color: var(--text2);
}

.pin-input {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.pin-input input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--mono);
    outline: none;
}

.pin-input input:focus { border-color: var(--accent); }

/* ========== SCANNING ========== */
.scan-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.scan-line {
    width: 80%;
    height: 2px;
    background: var(--accent);
    animation: scanMove 1.4s ease-in-out infinite;
}

@keyframes scanMove {
    0%, 100% { transform: translateY(-40px); }
    50% { transform: translateY(40px); }
}

/* Sidebar overlay - always out of flow */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    display: none !important;
}
.sidebar-overlay.active { display: block !important; }

/* ========== UTILITIES ========== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.opacity-0 { opacity: 0; }
.pointer { cursor: pointer; }

/* ========== MOBILE BOTTOM NAV BAR ========== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    justify-content: space-around;
}

.mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 10px;
    padding: 4px 8px;
    cursor: pointer;
    min-width: 48px;
    transition: color 0.2s;
}

.mobile-bottom-nav button .nav-icon { font-size: 20px; }
.mobile-bottom-nav button.active { color: var(--accent); }
.mobile-bottom-nav button:active { transform: scale(0.95); }

@media (max-width: 768px) {
    .mobile-bottom-nav { display: flex; }

    /* Add padding at bottom of content so it doesn't hide behind bottom nav */
    .content { padding-bottom: 80px !important; }

    /* Make topbar more compact */
    .topbar { height: 48px; }
    #main { height: calc(100vh - 56px); height: calc(100dvh - 56px); }

    /* Better touch targets */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .form-control { min-height: 42px; font-size: 16px !important; /* prevents iOS zoom */ }
    select.form-control { min-height: 42px; }

    /* Item detail actions - stack vertically on mobile */
    .item-actions-mobile { flex-wrap: wrap !important; }
    .item-actions-mobile .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }

    /* Card grid - 2 columns on wider phones */
    .cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; }

    /* Table scrollable */
    .table-view { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-view table { min-width: 600px; }

    /* Stats grid on mobile */
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }

    /* Modal improvements */
    .modal { border-radius: var(--radius) var(--radius) 0 0 !important; max-height: 92vh !important; margin-top: auto; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 auto; min-width: 80px; justify-content: center; }

    /* FAB (floating action button) */
    #btn-add {
        position: fixed !important;
        bottom: 72px;
        right: 16px;
        z-index: 899;
        border-radius: 50% !important;
        width: 52px;
        height: 52px;
        padding: 0 !important;
        font-size: 24px !important;
        box-shadow: 0 4px 16px rgba(0,0,0,0.3);
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Hide text in add button, show just + */
    #btn-add { font-size: 0 !important; }
    #btn-add::before { content: '+'; font-size: 28px; }
}

@media (max-width: 480px) {
    .cards-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr !important; }
    .topbar-title { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ========== CUSTOM VAULT ICON ========== */
.vault-custom-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}
