@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Aref+Ruqaa:wght@400;700&family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --bg-color: #ffffff;
    --bg-gradient: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(212, 175, 55, 0.25);
    --glass-shadow: 0 8px 40px 0 rgba(0,0,0,0.1), 0 0 30px rgba(212, 175, 55, 0.08);
    --text-main: #000000;
    --text-muted: #666666;
    --primary: #000000;
    --primary-hover: #333333;
    --primary-glow: rgba(0, 0, 0, 0.15);
    --secondary: #10b981;
    --secondary-hover: #059669;
    --danger: #ef4444;
    --node-bg: #ffffff;
    --node-border: #000000;
    --line-color: #000000;
    --highlight: #000000;
    --card-gradient: #ffffff;
    --card-glow: 0 0 20px rgba(212, 175, 55, 0.08);
}

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

body {
    background: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    display: none;
}

h1, h2, h3, h4 {
    font-family: 'Amiri', serif;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Amiri', serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.3px;
}

.primary-btn {
    background: linear-gradient(135deg, #d4af37, #aa8529);
    color: #000;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    border: none;
}

.primary-btn:hover {
    background: linear-gradient(135deg, #e8c84a, #b8952e);
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.4);
}

.secondary-btn {
    background-color: var(--secondary);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.secondary-btn:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
}

.outline-btn {
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--primary);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.outline-btn:hover {
    background-color: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.1);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
}

.icon-btn:hover {
    color: var(--highlight);
    transform: scale(1.1);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 14px;
    padding: 2rem;
}

.modern-input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    resize: vertical;
}

.modern-input:focus {
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.08);
}

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

.input-group {
    margin-bottom: 1.2rem;
    position: relative;
    text-align: right;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
}

.view-container {
    display: none;
    height: 100vh;
    width: 100vw;
}

.view-container.active {
    display: flex;
    flex-direction: column;
}

.glass-header {
    background: #e0e0e0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-wrapper {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.logo-icon {
    font-size: 1.4rem;
    color: var(--primary);
    opacity: 0.8;
}

.header-left h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1;
    color: #000000;
    text-shadow: none;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 380px;
}

.search-box i {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
    transition: color 0.3s;
}

.search-box:focus-within i {
    color: var(--primary);
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: #f0f0f0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 30px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: all 0.35s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.search-box input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input:focus {
    border-color: rgba(0, 0, 0, 0.3);
    background: #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

.search-results {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 0.5rem;
}

.search-results.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.search-item {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.search-item:last-child {
    margin-bottom: 0;
}

.search-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
    padding-right: 1.3rem;
}

.header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-right .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.8);
    border-color: rgba(0,0,0,0.2);
    color: #000000;
}

.header-right .btn:hover {
    background: #ffffff;
    border-color: #000000;
    color: #000000;
}

.header-right .btn i {
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .hide-mobile { display: none; }
    .header-left h2 { font-size: 1rem; }
    .header-left .subtitle { display: none; }
    .glass-header { padding: 0.6rem 0.8rem; }
    .header-right .btn { padding: 0.35rem 0.6rem; font-size: 0.75rem; border-radius: 6px; }
    .header-right { gap: 0.25rem; }
    .search-box { max-width: 160px; }
    .search-box input { padding: 0.4rem 0.8rem 0.4rem 2rem; font-size: 0.85rem; }
    .search-box i { right: 0.8rem; font-size: 0.75rem; }
    .logo-wrapper { width: 34px; height: 34px; }
    .logo-icon { font-size: 1.1rem; }
    .control-btn { width: 34px; height: 34px; font-size: 0.8rem; }
    .fab { width: 48px; height: 48px; font-size: 1.3rem; bottom: 1rem; right: 1rem; }
    .tree-controls { bottom: 1rem; left: 1rem; }
    .modal-panel { margin: 1rem; }
    .list-item { padding: 0.8rem 1rem; }
    .list-item-actions { opacity: 1; }
    .list-item-actions button { width: 30px; height: 30px; font-size: 0.75rem; }
}

.active-view {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

.tree-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.tree-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.03), transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(212, 175, 55, 0.02), transparent 50%);
    pointer-events: none;
}

.tree-wrapper:active {
    cursor: grabbing;
}

.d3-container {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.royal-card {
    background: #ffffff;
    border: 1.5px solid #000000;
    border-radius: 10px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.royal-card::before {
    display: none;
}

.royal-card::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 7px;
    pointer-events: none;
}

.royal-card-inner {
    padding: 0.15rem 0.4rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.royal-name {
    font-family: 'Aref Ruqaa', serif;
    font-size: 1.25rem;
    color: #000000;
    text-shadow: none;
    line-height: 1.2;
    transition: color 0.3s;
}

.royal-card:hover {
    border-color: #000000;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
    transform: scale(1.08);
}

.royal-card:hover .royal-name {
    color: var(--highlight);
}

.node.has-children .royal-card {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.8);
}

.node.has-children .royal-card:hover {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.node.highlighted .royal-card {
    border-color: #000000;
    background: #f0f0f0;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); }
    50% { box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); }
}

.node.highlighted .royal-name {
    color: #fff;
    text-shadow: 0 0 12px var(--highlight), 0 0 25px rgba(255, 215, 0, 0.3);
}

.node.dragging .royal-card {
    opacity: 0.7;
    transform: scale(0.95);
    border-color: var(--secondary);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.link {
    fill: none;
    stroke: #000000;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 1;
    filter: none;
    transition: all 0.4s ease;
}

.link.highlighted {
    stroke: #000000;
    stroke-width: 4px;
    opacity: 1;
    filter: none;
}

.tree-controls {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 100;
}

.control-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(8, 8, 8, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.15);
    backdrop-filter: blur(8px);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    transition: all 0.3s;
}

.control-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--primary);
    transform: scale(1.05);
}

.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37, #aa8529);
    color: #000;
    font-size: 1.5rem;
    border: none;
    box-shadow: 0 4px 25px rgba(212, 175, 55, 0.3), 0 0 40px rgba(212, 175, 55, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 35px rgba(212, 175, 55, 0.5), 0 0 60px rgba(212, 175, 55, 0.12);
}

.fab:active {
    transform: scale(0.95);
}

.list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.list-wrapper::-webkit-scrollbar { width: 6px; }
.list-wrapper::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.2); border-radius: 3px; }

.list-container {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-bottom: 2rem;
}

.list-item {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-right: 3px solid rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.list-item:hover {
    transform: translateX(-3px);
    border-color: rgba(0, 0, 0, 0.2);
    border-right-color: rgba(0, 0, 0, 0.8);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.list-item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.list-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.list-item-details h4 {
    font-size: 1.2rem;
    font-family: 'Aref Ruqaa', serif;
    color: var(--text-main);
    margin-bottom: 2px;
    font-weight: 400;
}

.list-item-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
}

.list-item-actions {
    display: flex;
    gap: 0.4rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.list-item:hover .list-item-actions {
    opacity: 1;
}

.list-item-actions button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s;
    background: rgba(0,0,0,0.6);
    font-size: 0.85rem;
}

.btn-edit-list { color: var(--primary) !important; border-color: rgba(212, 175, 55, 0.2) !important; }
.btn-edit-list:hover { background: rgba(212, 175, 55, 0.15); color: var(--primary-hover) !important; }

.btn-add-list { color: var(--secondary) !important; border-color: rgba(16, 185, 129, 0.2) !important; }
.btn-add-list:hover { background: rgba(16, 185, 129, 0.15); color: var(--secondary-hover) !important; }

.btn-delete-list { color: var(--danger) !important; border-color: rgba(239, 68, 68, 0.2) !important; }
.btn-delete-list:hover { background: rgba(239, 68, 68, 0.15); color: #fff !important; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-panel {
    width: 100%;
    max-width: 460px;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 1.5rem;
    background: #ffffff;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 0.8rem;
}

.modal-header h3 {
    color: var(--primary);
    font-size: 1.2rem;
    font-family: 'Amiri', serif;
}

.modal-header .icon-btn {
    opacity: 0.5;
    transition: opacity 0.3s;
}

.modal-header .icon-btn:hover {
    opacity: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.input-group textarea.modern-input {
    min-height: 80px;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.3);
}

.d3-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.92);
    border: 1px solid rgba(212, 175, 55, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: 'Tajawal', sans-serif;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.9), 0 0 15px rgba(212, 175, 55, 0.05);
    z-index: 500;
    opacity: 0;
    transition: opacity 0.2s;
}

body.preview-mode .glass-header {
    display: none !important;
}

body.preview-mode .fab,
body.preview-mode .tree-controls {
    display: none !important;
}

body.preview-mode .tree-wrapper {
    background: radial-gradient(ellipse at 50% 30%, rgba(212, 175, 55, 0.04), transparent 50%);
}

body.preview-mode .fab-close-preview {
    display: flex !important;
}

.fab-close-preview {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
    background: rgba(0,0,0,0.8);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: var(--text-muted);
    backdrop-filter: blur(10px);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.3s;
}
.fab-close-preview:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--primary);
}

.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, rgba(8,8,8,0.96), rgba(15,12,8,0.96));
    backdrop-filter: blur(12px);
    color: var(--text-main);
    border: 1px solid rgba(212, 175, 55, 0.15);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.9), 0 0 30px rgba(212, 175, 55, 0.05);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification i {
    color: var(--secondary);
    font-size: 1.1rem;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.link-gradient {
    stroke: url(#goldGradient);
}
