:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* -------------------- LOGIN SCREEN -------------------- */
#login-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeUp 0.6s ease-out;
}

.logo-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.glass-panel h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.glass-panel p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 15px;
    line-height: 1.5;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 20px;
}

.input-group input {
    width: 100%;
    padding: 18px 20px 18px 50px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

#login-btn {
    width: 100%;
    padding: 18px;
    border-radius: 16px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#login-btn:active {
    transform: scale(0.98);
}

.error-msg {
    color: var(--danger) !important;
    font-size: 14px !important;
    margin-bottom: 15px !important;
    display: none;
}

/* -------------------- MAIN APP APP -------------------- */
header {
    padding: 24px 20px 20px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--card-border);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-top h2 {
    font-weight: 700;
    font-size: 24px;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#logout-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

#logout-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.search-container {
    position: relative;
}

.search-container i.ri-search-line {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-container input {
    width: 100%;
    padding: 14px 40px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: white;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

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

#clear-search {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
}

.hidden {
    display: none !important;
}

/* -------------------- DIRECTORY LIST -------------------- */
main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px;
}

.loading-state {
    text-align: center;
    padding: 50px 0;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s infinite linear;
    margin: 0 auto 15px;
}

.person-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    animation: fadeUp 0.4s ease-out;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.card-header-main {
    display: flex;
    align-items: center;
    flex: 1;
}

.profile-pic {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    border: 2px solid var(--accent);
    background: rgba(255,255,255,0.1);
}

.edit-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
    transition: color 0.2s;
}

.edit-btn:hover {
    color: var(--accent);
}

.card-title h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-title .jf {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

.badge-age {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-dead {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #cbd5e1;
}

.detail-row i {
    color: var(--text-secondary);
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.detail-row a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.relation-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}

.relation-btn {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    outline: none;
}

.relation-btn:hover {
    background: rgba(255,255,255,0.15);
}

.relation-btn i {
    margin-right: 5px;
    color: var(--accent);
    font-size: 16px;
    vertical-align: middle;
}

#offline-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #f59e0b;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
    z-index: 1000;
}

/* -------------------- MODAL -------------------- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeUp 0.3s ease-out;
}
.modal-content h3 { margin-bottom: 20px; font-size: 20px; }
.modal-content label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--text-secondary); }
.modal-content input {
    width: 100%; padding: 10px; border-radius: 8px;
    border: 1px solid var(--card-border); background: rgba(0,0,0,0.2);
    color: white; margin-bottom: 15px; outline: none; font-family: 'Outfit';
}
.modal-content input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 10px; }
.btn-cancel { flex: 1; padding: 12px; border-radius: 8px; border: none; background: rgba(255,255,255,0.1); color: white; cursor: pointer; font-family: 'Outfit'; }
.btn-save { flex: 1; padding: 12px; border-radius: 8px; border: none; background: var(--accent); color: white; cursor: pointer; font-weight: bold; font-family: 'Outfit'; }

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.no-results i {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
    opacity: 0.5;
}

/* -------------------- ANIMATIONS -------------------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* -------------------- TREES (ASSCENDANT/DESCENDANT) -------------------- */
.tree-person {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 8px 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.tree-person:hover {
    background: rgba(255,255,255,0.1);
}

.tree-person:active {
    transform: scale(0.98);
}

.tree-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    background: var(--card-border);
    border: 1px solid var(--accent);
}

.tree-info {
    display: flex;
    flex-direction: column;
}

.tree-info strong {
    font-size: 14px;
    color: var(--text-primary);
}

.tree-meta {
    font-size: 12px;
    color: var(--text-secondary);
}
