* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #090502;
    --bg-secondary: #120b06;
    --bg-tertiary: #1a120b;
    --text-primary: #f3e9dc;
    --text-secondary: #a89680;
    --accent-primary: #e07a3f;
    --accent-success: #8a9a5b;
    --accent-danger: #c0563a;
    --accent-warning: #d9a441;
    --border-color: #221a10;
    --btn-border-color: #ffffff;
}

/* ── LIGHT MODE ───────────────────────────────────────── */
/* Backgrounds/text unchanged from before — only the accent (button) colors shift to match the new coffee theme */
body.light-mode {
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --accent-primary: #b8541f;
    --accent-success: #059669;
    --accent-danger: #a8452f;
    --accent-warning: #d97706;
    --btn-border-color: #111827;
    --border-color: #d1d5db;
}

body {
    font-family: -apple-system, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 30px;
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

/* ── FIX 1: Theme toggle button ──────────────────────── */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: 0.2s;
}

.theme-toggle:hover {
    opacity: 0.8;
}

/* Admin button: always white text on red bg */
.btn-danger {
    background: var(--accent-danger);
    color: #ffffff !important;
    border: 1.5px solid var(--btn-border-color);
}

/* ── HOME VIEW ────────────────────────────────────────── */
.home-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 10px;
}

@media (max-width: 480px) {
    .home-grid { grid-template-columns: 1fr; }
}

.home-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 36px 20px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: border-color 0.2s, transform 0.15s, background 0.2s;
}

.home-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    background: var(--bg-tertiary);
}

.home-btn-icon {
    font-size: 30px;
}

/* ── BACK BUTTON ──────────────────────────────────────── */
.back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 10px;
    font-size: 14px;
}

.back-btn:hover {
    color: var(--accent-primary);
}

/* ── ADMIN FAB ────────────────────────────────────────── */
.admin-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent-danger);
    color: #ffffff !important;
    border: none;
    padding: 12px 18px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    z-index: 1500;
    transition: opacity 0.2s, transform 0.15s;
}

.admin-fab:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* ── CHECKBOX ROW (vault) ─────────────────────────────── */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

/* ── TAB CONTENT (now used for create/search/delete/vault views) ── */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── CARD ─────────────────────────────────────────────── */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* FIX 3: Post result card border states */
.card.card-success {
    border: 2px solid var(--accent-success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.card.card-error {
    border: 2px solid var(--accent-danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* ── INPUTS ───────────────────────────────────────────── */
input,
textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    margin-top: 5px;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

.form-group label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    margin: 15px 0;
    color: var(--text-secondary);
    transition: border-color 0.2s, background 0.2s;
}

.file-upload:hover {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: opacity 0.2s, transform 0.1s;
}

.btn:hover:not(:disabled) {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff !important;
    border: 1.5px solid var(--btn-border-color);
}

/* ── FIX 2: Alert box — always visible, properly boxed ── */
.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 18px;
    border-radius: 8px;
    display: none;
    z-index: 2000;
    min-width: 260px;
    max-width: 360px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    border: 1.5px solid transparent;
    animation: slideIn 0.25s ease;
}

.alert.show {
    display: block;
}

.alert.alert-success {
    background: #052e16;
    color: #6ee7b7;
    border-color: #059669;
}

body.light-mode .alert.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #059669;
}

.alert.alert-error {
    background: #450a0a;
    color: #fca5a5;
    border-color: #dc2626;
}

body.light-mode .alert.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #dc2626;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── POST ITEMS ───────────────────────────────────────── */
.post-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

/* ── ADMIN STATS ──────────────────────────────────────── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

/* FIX 5 & 6: Stat cards — values always readable */
.stat-card {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-card small {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── LOADING SPINNER ──────────────────────────────────── */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── MODAL ────────────────────────────────────────────── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-content h3 {
    color: var(--text-primary);
    margin-bottom: 4px;
}

/* ── VAULT CODE FIELD (masked, with show/hide) ────────── */
.password-field-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-top: 5px;
}

.password-field-row input {
    margin-top: 0;
    flex: 1;
}

.toggle-visibility-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.toggle-visibility-btn:hover {
    color: var(--text-primary);
}

/* ── VAULT NAME PROMPT (new vault) ───────────────────── */
.vault-name-prompt {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ── ADMIN HEADER ─────────────────────────────────────── */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header h2 {
    color: var(--text-primary);
}

/* ── VAULT ACTION ROW (Files button + reserved slots) ── */
.vault-actions {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 20px;
}

/* Empty placeholders — future vault buttons drop in here */
.vault-slot {
    min-width: 0;
}

.vault-action-btn {
    grid-column: 2;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px 16px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color 0.2s, transform 0.15s, background 0.2s;
}

.vault-action-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    background: var(--bg-tertiary);
}

.vault-action-btn.active {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.vault-action-icon {
    font-size: 26px;
    line-height: 1;
}

@media (max-width: 480px) {
    .vault-actions { gap: 10px; }
    .vault-action-btn { padding: 14px 8px; font-size: 15px; }
}

/* ── ADMIN DASHBOARD TABLE ────────────────────────────── */
.admin-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.admin-stats .stat-card {
    border-top: 2px solid var(--accent-primary);
}

.admin-section-title {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 4px 0 10px;
}

.admin-table {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.admin-table-head,
.admin-row {
    display: grid;
    grid-template-columns: 1.1fr 1.1fr 1.3fr 64px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
}

.admin-table-head {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.admin-row {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    transition: background 0.2s;
}

.admin-row:last-child {
    border-bottom: none;
}

.admin-row:hover {
    background: var(--bg-secondary);
}

.admin-cell {
    min-width: 0;
    overflow-wrap: anywhere;
}

.admin-cell strong,
.admin-cell code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.admin-cell-action {
    text-align: right;
}

.admin-cell-action .btn {
    width: auto;
    padding: 4px 12px;
}

@media (max-width: 480px) {
    .admin-table-head,
    .admin-row {
        grid-template-columns: 1fr 1fr 1fr 52px;
        gap: 8px;
        padding: 10px 10px;
    }
    .admin-cell strong,
    .admin-cell code { font-size: 12px; }
}
