/* ============================================
   Family Network Graph - Styles
   ============================================ */

/* ============================================
   Theme Variables - Light (Only Theme)
   ============================================ */

:root {
    /* Color Palette */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e5ea;

    --text-primary: #1c1c1e;
    --text-secondary: #636366;
    --text-muted: #8e8e93;

    /* Node Colors */
    --male-primary: #2563eb;
    --male-secondary: #1d4ed8;
    --male-glow: rgba(37, 99, 235, 0.3);

    --female-primary: #db2777;
    --female-secondary: #be185d;
    --female-glow: rgba(219, 39, 119, 0.3);

    /* Edge Colors */
    --edge-father: #2563eb;
    --edge-mother: #db2777;
    --edge-spouse: #16a34a;

    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.2);

    /* Expand indicator */
    --expand-bg: #e5e5ea;
    --expand-border: #8e8e93;
    --expand-text: #1c1c1e;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Kufi Arabic', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Graph Container */
#graph-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
}

#graph-container:active {
    cursor: grabbing;
}

#graph-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Controls */
.controls {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Legend */
.legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-tertiary);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-fast);
}

.legend-header:hover {
    background: var(--bg-tertiary);
}

.legend-header-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-toggle-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.legend.collapsed .legend-toggle-icon {
    transform: rotate(180deg);
}

.legend-content {
    padding: 12px 16px 16px;
    max-height: 300px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.legend.collapsed .legend-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.legend.collapsed .legend-header {
    border-bottom-color: transparent;
}

.legend:not(.collapsed) .legend-header {
    border-bottom-color: var(--bg-tertiary);
}

.legend-section {
    margin-bottom: 12px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.legend-color.node-male {
    background: var(--male-primary);
    border: 2px solid var(--male-secondary);
}

.legend-color.node-female {
    background: var(--female-primary);
    border: 2px solid var(--female-secondary);
}

.legend-line {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.edge-father {
    background: var(--edge-father);
}

.legend-line.edge-mother {
    background: var(--edge-mother);
}

.legend-line.edge-spouse {
    background: var(--edge-spouse);
    background: repeating-linear-gradient(to right,
            var(--edge-spouse) 0px,
            var(--edge-spouse) 6px,
            transparent 6px,
            transparent 10px);
}

/* Loading */
.loading {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 1000;
    transition: opacity var(--transition-normal);
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Tooltip */
.tooltip {
    position: fixed;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 200;
    max-width: 300px;
    direction: rtl;
    text-align: right;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.tooltip-info {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   SVG Styles
   ============================================ */

/* Edges */
.edge {
    stroke-opacity: 0.7;
    transition: stroke-opacity var(--transition-fast);
}

.edge:hover {
    stroke-opacity: 1;
    stroke-width: 3px !important;
}

.edge-father {
    stroke: var(--edge-father);
}

.edge-mother {
    stroke: var(--edge-mother);
}

.edge-spouse {
    stroke: var(--edge-spouse);
}

/* Nodes */
.node {
    cursor: grab;
}

.node:active {
    cursor: grabbing;
}

.node-circle {
    transition: all var(--transition-fast);
}

.node-circle.male {
    fill: var(--male-primary);
    stroke: var(--male-secondary);
}

.node-circle.female {
    fill: var(--female-primary);
    stroke: var(--female-secondary);
}

.node:hover .node-circle {
    filter: drop-shadow(0 0 12px currentColor);
    stroke-width: 3px;
}

.node:hover .node-circle.male {
    filter: drop-shadow(0 0 15px var(--male-glow));
}

.node:hover .node-circle.female {
    filter: drop-shadow(0 0 15px var(--female-glow));
}

/* Node Labels */
.node-label {
    font-family: 'Noto Kufi Arabic', sans-serif;
    font-size: 11px;
    font-weight: 500;
    fill: var(--text-secondary);
    text-anchor: middle;
    pointer-events: none;
    direction: rtl;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .controls {
        top: 10px;
        left: 10px;
    }

    .control-btn {
        width: 38px;
        height: 38px;
    }

    .legend {
        bottom: 10px;
        left: 10px;
        padding: 12px 14px;
        font-size: 12px;
    }
}

/* Control Divider */
.control-divider {
    height: 1px;
    background: var(--bg-tertiary);
    margin: 4px 0;
}

/* Legend Icon (for +/- indicators) */
.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
}

/* Expand/Collapse Indicator */
.expand-indicator {
    transition: all var(--transition-fast);
    cursor: pointer;
}

.expand-indicator:hover {
    transform: scale(1.1);
}

.expand-icon {
    pointer-events: none;
    user-select: none;
}