/* Sweet Home — Premium Neumorphism Design System */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
    --bg: #ecf0f3;
    --bg-dark: #e2e6ea;
    --text: #4a5568;
    --text-dark: #1a202c;
    --text-muted: #94a3b8;
    --shadow-dark: rgba(163, 177, 198, 0.7);
    --shadow-light: rgba(255, 255, 255, 0.95);
    --accent: #4f46e5;
    --accent-hover: #3730a3;
    --accent-light: #818cf8;
    --accent-bg: rgba(79, 70, 229, 0.08);
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --nav-height: 72px;
    --header-height: 64px;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ─── Neumorphic Surfaces ─────────────────────────────────────────────────────── */
.neo-flat {
    background: var(--bg);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.3);
}

.neo-flat-sm {
    background: var(--bg);
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.2);
}

.neo-flat-xs {
    background: var(--bg);
    box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
    border-radius: var(--radius-xs);
}

.neo-inset {
    background: var(--bg);
    box-shadow: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.1);
}

.neo-inset-sm {
    background: var(--bg);
    box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
    border-radius: var(--radius-sm);
}

.neo-card {
    background: var(--bg);
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.25);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.neo-card:hover {
    box-shadow: 10px 10px 20px var(--shadow-dark), -10px -10px 20px var(--shadow-light);
    transform: translateY(-2px);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.neo-button {
    background: var(--bg);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s ease;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.neo-button:hover {
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transform: translateY(1px);
}

.neo-button:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    transform: translateY(2px);
}

.neo-button.active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    color: var(--accent);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 4px 4px 12px rgba(79,70,229,0.3), -2px -2px 8px rgba(255,255,255,0.5);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #3730a3);
    box-shadow: 6px 6px 16px rgba(79,70,229,0.4), -2px -2px 8px rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(1px); }

.btn-danger {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 3px 3px 10px rgba(239,68,68,0.25);
    transition: all 0.2s;
}

.btn-danger:hover { transform: translateY(-1px); box-shadow: 4px 4px 14px rgba(239,68,68,0.35); }

.btn-success {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 3px 3px 10px rgba(34,197,94,0.25);
    transition: all 0.2s;
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.75rem; }
.btn-xs { padding: 0.35rem 0.75rem; font-size: 0.7rem; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Inputs ─────────────────────────────────────────────────────────────────── */
.neo-input {
    background: var(--bg);
    border: 1.5px solid rgba(255,255,255,0.3);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    width: 100%;
    outline: none;
}

.neo-input:focus {
    box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light),
                0 0 0 2px var(--accent-light);
    border-color: var(--accent-light);
}

.neo-input::placeholder { color: var(--text-muted); }

select.neo-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.25rem; padding-right: 2.5rem; }

textarea.neo-input { resize: vertical; min-height: 80px; }

/* ─── Toggle ─────────────────────────────────────────────────────────────────── */
.neo-toggle-label {
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    background: var(--bg);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* ─── Progress Bar ───────────────────────────────────────────────────────────── */
.neo-progress {
    background: var(--bg);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    border-radius: 9999px;
    overflow: hidden;
}

.neo-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* ─── Badge ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.badge-mandatory { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.badge-optional { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef9c3; color: #ca8a04; }
.badge-danger { background: #fee2e2; color: #dc2626; }

/* ─── App Layout ─────────────────────────────────────────────────────────────── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 100;
    background: var(--bg);
    box-shadow: 0 4px 12px var(--shadow-dark), 0 -2px 8px var(--shadow-light);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
}

.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 100;
    background: var(--bg);
    box-shadow: 0 -4px 12px var(--shadow-dark), 0 2px 8px var(--shadow-light);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.5rem;
}

.app-content {
    padding-top: calc(var(--header-height) + 0.75rem);
    padding-bottom: calc(var(--nav-height) + 1rem);
    padding-left: 0.875rem;
    padding-right: 0.875rem;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    min-width: 52px;
}

.nav-item i { font-size: 1.1rem; transition: all 0.2s; }

.nav-item.active {
    color: var(--accent);
    background: var(--accent-bg);
    box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.nav-item:not(.active):hover { color: var(--accent); }

/* ─── Accordion / Tabs ───────────────────────────────────────────────────────── */
.tab-body { display: none; }
.tab-body.open { display: block; animation: fadeSlideIn 0.3s ease; }
.chevron { transition: transform 0.3s; display: inline-block; }
.chevron.rotated { transform: rotate(180deg); }

/* ─── Avatar ─────────────────────────────────────────────────────────────────── */
.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
    border: 2px solid rgba(255,255,255,0.6);
}

.avatar-placeholder {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
    flex-shrink: 0;
}

/* ─── Stat Cards ─────────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--bg);
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border: 1px solid rgba(255,255,255,0.25);
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,20,40,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-sheet {
    background: var(--bg);
    box-shadow: 0 -8px 32px var(--shadow-dark), 0 8px 32px rgba(0,0,0,0.15);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(40px);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding: 1.25rem;
}

.modal-overlay.open .modal-sheet { transform: translateY(0); }

.modal-center {
    align-items: center;
}

.modal-center .modal-sheet {
    border-radius: var(--radius);
    max-width: 360px;
    transform: scale(0.9);
}

.modal-overlay.open.modal-center .modal-sheet { transform: scale(1); }

.modal-handle {
    width: 2.5rem;
    height: 0.25rem;
    background: var(--shadow-dark);
    border-radius: 9999px;
    margin: 0 auto 1rem;
}

/* ─── User Assign Input ──────────────────────────────────────────────────────── */
.user-assign-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 1rem; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid rgba(79,70,229,0.2);
    border-radius: 9999px;
    padding: 0.2rem 0.5rem 0.2rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.user-chip button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.user-chip button:hover { opacity: 1; }

.user-search-results {
    position: absolute;
    left: 0; right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    background: var(--bg);
    box-shadow: 6px 6px 16px var(--shadow-dark), -6px -6px 16px var(--shadow-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-height: 200px;
    overflow-y: auto;
}

.user-search-result-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
    font-size: 0.8rem;
    font-weight: 500;
}

.user-search-result-item:hover { background: var(--accent-bg); color: var(--accent); }

/* ─── Impersonation Banner ───────────────────────────────────────────────────── */
.impersonation-banner {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #78350f;
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
}

.has-banner .app-header { top: 2.25rem; }
.has-banner .app-content { padding-top: calc(var(--header-height) + 2.25rem + 0.75rem); }

/* ─── Form Section ───────────────────────────────────────────────────────────── */
.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.form-label-text {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-label-required { color: var(--danger); }

/* ─── File Upload ────────────────────────────────────────────────────────────── */
.file-drop-zone {
    padding: 1.1rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.file-drop-zone:hover { color: var(--accent); }

.file-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

/* ─── Search Bar ─────────────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.2);
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-dark);
    flex: 1;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.neo-table { width: 100%; border-collapse: collapse; }
.neo-table th {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); padding: 0.6rem 0.75rem;
    text-align: left; border-bottom: 2px solid rgba(163,177,198,0.3);
}
.neo-table td {
    padding: 0.75rem; font-size: 0.82rem; color: var(--text);
    border-bottom: 1px solid rgba(163,177,198,0.2); vertical-align: middle;
}
.neo-table tr:last-child td { border-bottom: none; }

/* ─── Section Header ─────────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; opacity: 0.4; }
.empty-state p { font-size: 0.875rem; font-weight: 500; }

/* ─── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes softPulse {
    0%   { box-shadow: 0 0 0 0 rgba(79,70,229,0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(79,70,229,0); }
    100% { box-shadow: 0 0 0 0 rgba(79,70,229,0); }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.fade-in  { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.35s ease; }
.soft-pulse { animation: softPulse 2s infinite; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    z-index: 500;
    white-space: nowrap;
    animation: slideUp 0.3s ease;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}

.toast-success { background: linear-gradient(135deg,#4ade80,#22c55e); color: white; }
.toast-error   { background: linear-gradient(135deg,#f87171,#ef4444); color: white; }
.toast-info    { background: linear-gradient(135deg,#6366f1,#4f46e5); color: white; }

/* ─── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── OCR Panel ──────────────────────────────────────────────────────────────── */
.ocr-panel { border-radius: var(--radius-sm); padding: 0.75rem; }

/* ─── Notification Dot ───────────────────────────────────────────────────────── */
.notif-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 0.55rem; height: 0.55rem;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg);
}

/* ─── Building / Flat Cards ──────────────────────────────────────────────────── */
.entity-card {
    background: var(--bg);
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(255,255,255,0.25);
}

.entity-card:hover {
    box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
    transform: translateY(-2px);
}

.entity-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

/* ─── Dashboard Grid ─────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* ─── OCR Progress ───────────────────────────────────────────────────────────── */
.neo-progress-bar { height: 6px; border-radius: 9999px; }

/* ─── User Management Table Wrapper ─────────────────────────────────────────── */
.table-wrapper {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    background: var(--bg);
}

/* ─── Responsive adjustments ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
    .app-content { padding-left: 1.25rem; padding-right: 1.25rem; }
    .modal-sheet { border-radius: var(--radius); }
}
