/* assets/css/style.css */
:root {
    --background: #f8fafc; /* Lighter background */
    --foreground: #0f172a;
    
    --card: #ffffff;
    --card-foreground: #0f172a;
    
    --border: #e2e8f0;
    --input: #e2e8f0;
    
    --primary: #0f172a;
    --primary-foreground: #f8fafc;
    
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    
    --muted: #f8fafc;
    --muted-foreground: #64748b;
    
    --destructive: #ef4444;
    --destructive-foreground: #ffffff;
    
    --success: #10b981;
    --success-foreground: #ffffff;
    
    --radius: 0.5rem; /* 8px - Softer corners */
    --font-sans: "Inter", sans-serif;
}

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

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 14px; /* Back to readable 14px */
    line-height: 1.6; /* Increased line height */
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* LAYOUT */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px; /* Wider sidebar */
    background: #fff;
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem; /* More padding around content */
    width: calc(100% - 260px);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem; /* More space below header */
}
.header h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; }
.header p { font-size: 14px; color: var(--muted-foreground); margin-top: 4px; }

/* SIDEBAR NAV */
.logo { 
    font-weight: 700; font-size: 18px; margin-bottom: 2rem; 
    display: flex; align-items: center; gap: 10px; color: var(--primary);
}
.nav-item a {
    display: flex; align-items: center; gap: 12px;
    padding: 0.75rem 1rem; /* Larger touch targets */
    border-radius: var(--radius);
    color: var(--muted-foreground);
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}
.nav-item a:hover { background: var(--secondary); color: var(--foreground); }
.nav-item a.active { background: var(--primary); color: var(--primary-foreground); }

/* CARDS */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem; /* More space between cards */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Slightly softer shadow */
}
.card-header {
    padding: 1.25rem 1.5rem; /* More header padding */
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-title { font-size: 16px; font-weight: 600; margin: 0; }
.card-content { padding: 1.5rem; } /* Comfortable content padding */

/* FORMS */
.form-group { margin-bottom: 1.25rem; }
.label {
    display: block; font-size: 13px; font-weight: 500; margin-bottom: 0.5rem;
    color: var(--foreground);
}
.input {
    width: 100%;
    height: 2.5rem; /* 40px - Standard Modern Size */
    padding: 0 0.75rem;
    font-size: 14px;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background: #fff;
    color: var(--foreground);
    transition: border 0.15s ease;
}
.input:focus { outline: none; border-color: var(--primary); ring: 2px solid var(--secondary); }

/* Select2 Fix for new Height */
.select2-container .select2-selection--single { height: 2.5rem !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 2.5rem !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 2.5rem !important; }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 2.5rem; /* 40px */
    padding: 0 1.25rem;
    font-size: 14px; font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer; border: none;
    transition: opacity 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--secondary); }

/* TABLE */
.table-container { width: 100%; overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; padding: 1rem 1.5rem; /* Spacious headers */
    background: var(--secondary); color: var(--muted-foreground);
    font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--border);
}
.table td {
    padding: 1rem 1.5rem; /* Spacious cells */
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background-color: #fafafa; }

/* BADGES */
.badge {
    display: inline-flex; padding: 0.25rem 0.75rem;
    border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge-active { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge-inactive { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* GRID UTILITIES */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

/* UTILS */
.text-right { text-align: right; }
.mb-4 { margin-bottom: 1.5rem; }

/* ------------------------------------------------------------------
   GENEALOGY TREE CSS (Pure CSS Org Chart)
------------------------------------------------------------------ */
.tree-container {
    overflow-x: auto;
    padding: 2rem;
    min-height: 500px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.tree {
    white-space: nowrap;
    display: inline-block;
    min-width: 100%;
}

.tree ul {
    padding-top: 20px; 
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.tree li {
    float: left; text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}

/* Connectors */
.tree li::before, .tree li::after {
    content: ''; position: absolute; top: 0; right: 50%;
    border-top: 1px solid var(--border);
    width: 50%; height: 20px;
}
.tree li::after {
    right: auto; left: 50%;
    border-left: 1px solid var(--border);
}

/* Remove connectors from root */
.tree li:only-child::after, .tree li:only-child::before {
    display: none;
}
.tree li:only-child { padding-top: 0; }

/* Remove left connector from first child and right from last child */
.tree li:first-child::before, .tree li:last-child::after {
    border: 0 none;
}
/* Add vertical connector back for single last child */
.tree li:last-child::before {
    border-right: 1px solid var(--border);
    border-radius: 0 5px 0 0;
}
.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Downward connector from parent */
.tree ul::before {
    content: ''; position: absolute; top: 0; left: 50%;
    border-left: 1px solid var(--border);
    width: 0; height: 20px;
}

/* THE NODE CARD */
.tree-node {
    border: 1px solid var(--border);
    padding: 10px;
    display: inline-block;
    border-radius: var(--radius);
    background: white;
    text-decoration: none;
    transition: all 0.2s;
    min-width: 120px;
    position: relative;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.tree-node:hover {
    background: var(--secondary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.node-active { border-top: 3px solid var(--success); }
.node-inactive { border-top: 3px solid var(--muted-foreground); background: #f8fafc; color: var(--muted-foreground); }

.node-name { font-weight: 600; font-size: 13px; display: block; margin-bottom: 2px;}
.node-user { font-size: 11px; color: var(--muted-foreground); display: block; }
.node-count { 
    font-size: 10px; background: var(--secondary); 
    padding: 2px 6px; border-radius: 10px; margin-top: 6px; display: inline-block; 
}

/* MOBILE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
    .main-content { margin-left: 0; padding: 1rem; margin-top: 60px; width: 100%; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 1rem; }
}