/* Reset dan Pengaturan Dasar */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.5;
    padding-top: 64px;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* App Bar */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: #1877f2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
}

.app-bar h1 {
    font-size: 20px;
    font-weight: 500;
    flex: 1;
}

.home-link-btn {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
}

.home-link-btn:hover, .home-link-btn:active {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.admin-link-btn {
    color: #ffffff; /* Putih bersih untuk kontras tinggi */
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15); /* Sedikit lebih terang dari bar */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); /* Berikan bayangan agar menonjol */
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.admin-link-btn:hover {
    background: #ffffff;
    color: #1877f2; /* Balik warna saat hover */
    transform: scale(1.1); /* Efek membesar saat hover */
}

.admin-link-btn .material-icons {
    font-size: 36px; /* Ikon besar */
}

.home-link-btn .material-icons {
    font-size: 20px;
}

/* Container Utama */
.container {
    padding: 8px;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
}

/* Silsilah Container */
#silsilah-container {
    flex: 1;
    overflow: auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    position: relative;
    text-align: center;
    -webkit-overflow-scrolling: touch;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 12px 6px;
    background: white;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    border-right: 1px solid #f0f0f0;
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.65rem;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 2px;
    text-align: center;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #1877f2;
}

#orgchart-container {
    min-width: 100%;
    display: inline-block;
}

/* Override JQuery OrgChart Styles */
div.orgChart {
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
}

div.orgChart table {
    border-collapse: separate;
    border-spacing: 0;
    width: auto;
    margin: 0 auto;
}

div.orgChart td {
    padding: 0;
    margin: 0;
    vertical-align: top;
    box-sizing: content-box !important;
}

div.orgChart div.node {
    width: 110px;
    height: auto;
    min-height: 80px;
    padding: 10px 4px;
    border: 2px solid #ccc;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    background-color: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1.2;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.node-photo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-bottom: 6px;
    overflow: hidden;
    border: 2px solid rgba(0,0,0,0.1);
}

.node-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-photo.default {
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-photo.default .material-icons {
    font-size: 28px;
    color: #999;
}

div.orgChart div.node.hasChildren {
    cursor: pointer;
}

/* Hapus ikon expand yang muncul sebagai teks */
div.orgChart div.node.hasChildren::after,
div.orgChart div.node.shownChildren::after {
    display: none !important;
}

div.orgChart div.node strong {
    display: block;
    color: #333;
    font-size: 0.9em;
    text-align: center;
}

div.orgChart div.node small {
    display: block;
    color: #777;
    font-size: 0.7em;
    margin-top: 2px;
}

div.orgChart li.male > div.node {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

div.orgChart li.female > div.node {
    background-color: #fce4ec;
    border-color: #e91e63;
}

div.orgChart li.unknown > div.node {
    background-color: #f5f5f5;
    border-color: #999;
}

div.orgChart tr.lines td.line {
    height: 20px;
    width: 50%;
}

div.orgChart tr.lines td.top {
    border-top: 2px solid #888;
}

div.orgChart tr.lines td.left {
    border-right: 1px solid #888;
}

div.orgChart tr.lines td.right {
    border-left: 1px solid #888;
}

div.orgChart tr.lines.v td:first-child.left,
div.orgChart tr.lines.v td:last-child.right {
    border: none;
}

/* Admin Page Specific */
.admin-page {
    display: flex;
    justify-content: center;
}

.admin-wrapper {
    width: 100%;
    max-width: 768px; /* Tablet width */
    min-height: 100vh;
    background: #f0f2f5;
    position: relative;
}

.admin-container {
    padding: 16px;
    padding-bottom: 20px;
}

.admin-section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: #1877f2;
    padding-left: 8px;
    border-left: 4px solid #1877f2;
}

.card-form {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
}

.radio-group-modern {
    display: flex;
    gap: 10px;
}

.radio-group-modern input {
    display: none;
}

.radio-group-modern label {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
}

.radio-group-modern input:checked + label {
    background: #1877f2;
    color: white;
}

.submit-btn-modern {
    width: 100%;
    padding: 12px;
    background: #1877f2;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}

/* Table and Search */
.list-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    background: white;
    padding: 8px 16px;
    border-radius: 24px;
    border: 1px solid #e0e0e0;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    margin-left: 8px;
}

.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th {
    text-align: left;
    background: #f8f9fa;
    padding: 12px;
    color: #666;
    border-bottom: 2px solid #eee;
}

.modern-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.action-btns {
    display: flex;
    gap: 8px;
}

.btn-icon {
    border: none;
    background: #f0f2f5;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon .material-icons {
    font-size: 18px;
}

.btn-icon.edit { color: #1877f2; }
.btn-icon.edit:hover { background: #e3f2fd; }

.btn-icon.delete { color: #f44336; }
.btn-icon.delete:hover { background: #ffebee; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: white;
    width: 90%;
    max-width: 450px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 16px 20px;
    background: #1877f2;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.modal-close {
    cursor: pointer;
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    position: relative;
    overflow-y: visible; /* Biar dropdown tidak terpotong */
}

/* Custom Searchable Select */
.searchable-select {
    position: relative;
    width: 100%;
}

.select-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: text;
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 5000;
    display: none;
    border: 1px solid #eee;
}

.select-dropdown.active {
    display: block;
}

.select-option {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f9f9f9;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.select-option:last-child {
    border-bottom: none;
}

.select-option:hover {
    background: #f0f7ff;
}

.select-option.selected {
    background: #1877f2;
    color: white;
}

.select-option .option-info {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

.no-results {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

.table-small-text {
    font-size: 0.75rem;
    color: #888;
}

/* Tab System */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 768px;
    height: 64px;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    border-top: 1px solid #eee;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8e8e8e;
    text-decoration: none;
    font-size: 0.7rem;
    flex: 1;
    transition: color 0.2s;
    cursor: pointer;
}

.nav-item .material-icons {
    font-size: 24px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: #1877f2;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: #1877f2;
    color: white;
    border-color: #1877f2;
}

.page-info {
    font-size: 0.9rem;
    color: #666;
}

/* Info & Settings Section */
.info-card, .settings-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.info-item .material-icons {
    color: #1877f2;
}

.settings-list {
    list-style: none;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.settings-item:last-child {
    border-bottom: none;
}

@media (min-width: 600px) {
    .admin-container { padding: 24px; }
    .list-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .search-box { width: 300px; }
}
