/* 
 * Sitemap Visual Explorer Styles
 * Theme: Dark Mode with Cyan/Purple Gradient Accents
 */

:root {
    --bg-dark: #0F172A;
    /* Slate 900 */
    --bg-surface: #1E293B;
    /* Slate 800 */
    --bg-elevated: #334155;
    /* Slate 700 */

    --primary: #38BDF8;
    /* Light Blue 400 */
    --primary-hover: #0EA5E9;
    /* Light Blue 500 */
    --accent: #818CF8;
    /* Indigo 400 */

    --text-main: #F8FAFC;
    /* Slate 50 */
    --text-muted: #94A3B8;
    /* Slate 400 */
    --border: #334155;
    /* Slate 700 */

    --pri-high: #34D399;
    /* Emerald 400 */
    --pri-med: #FBBF24;
    /* Amber 400 */
    --pri-low: #F87171;
    /* Red 400 */
    --pri-none: #94A3B8;
    /* Slate 400 */

    --font-main: 'Inter', system-ui, sans-serif;
    --radius-lg: 12px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.flex-1 {
    flex: 1;
}

.overflow-y {
    overflow-y: auto;
}

.overflow-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: 320px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(30, 41, 59, 1) 0%, rgba(15, 23, 42, 1) 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.logo h1 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-dark);
    padding: 0.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Forms */
textarea,
.text-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
    outline: none;
}

textarea {
    resize: none;
    height: 120px;
    margin-bottom: 0.75rem;
    font-family: monospace;
    font-size: 0.75rem;
}

textarea:focus,
.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.file-upload-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    background: var(--bg-dark);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.file-upload-block:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(56, 189, 248, 0.05);
}

.file-upload-block i {
    font-size: 1.5rem;
}

.file-upload-block span {
    font-size: 0.875rem;
    font-weight: 500;
}

.warn-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(251, 191, 36, 0.1);
    border-left: 3px solid var(--pri-med);
    padding: 0.5rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.warn-msg i {
    color: var(--pri-med);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.history-item:hover {
    background: var(--bg-dark);
}

.history-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hi-domain {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hi-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-del-history {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    padding: 0.25rem;
    transition: all 0.2s;
}

.history-item:hover .btn-del-history {
    opacity: 1;
}

.btn-del-history:hover {
    color: var(--pri-low);
}


/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.2);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 15px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    margin-top: auto;
    background: var(--bg-surface);
}

/* --- Workspace --- */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at top right, rgba(129, 140, 248, 0.05) 0%, transparent 50%), var(--bg-dark);
}

.toolbar {
    height: 64px;
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    flex-shrink: 0;
    z-index: 5;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-left h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.stats-badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.content-scroll {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    position: relative;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.tree-container:not(.empty) .empty-state {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--border), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    text-align: left;
    background: var(--bg-surface);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Tree Visualization --- */
.tree-container {
    min-width: fit-content;
    padding-bottom: 4rem;
    /* scroll padding */
}

/* The actual nested structure */
ul.tree-list {
    list-style: none;
    padding-left: 1.5rem;
    position: relative;
}

/* Hierarchy lines */
ul.tree-list::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--border);
}

.tree-node {
    margin: 0.25rem 0;
    position: relative;
}

.tree-node-content {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

/* Branch connector */
.tree-node::before {
    content: "";
    position: absolute;
    left: -1rem;
    top: 14px;
    /* rough vertical center of content */
    width: 0.75rem;
    height: 1px;
    background-color: var(--border);
}

.tree-node-content:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

.node-toggle-icon {
    font-size: 0.875rem;
    color: var(--text-muted);
    width: 14px;
    display: inline-flex;
    justify-content: center;
    transition: transform 0.2s;
}

.tree-node.expanded>.tree-node-content>.node-toggle-icon {
    transform: rotate(90deg);
}

/* Leaf nodes have no toggle */
.tree-node.leaf>.tree-node-content>.node-toggle-icon {
    visibility: hidden;
    width: 0;
}

.node-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.priority-dot.high {
    background: var(--pri-high);
    box-shadow: 0 0 5px var(--pri-high);
}

.priority-dot.med {
    background: var(--pri-med);
}

.priority-dot.low {
    background: var(--pri-low);
}

.priority-dot.none {
    background: var(--pri-none);
}

.node-children {
    display: none;
}

.tree-node.expanded>.node-children {
    display: block;
    animation: slideDown 0.2s ease-out forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Root node has no branch connector */
.tree-container>.tree-list {
    padding-left: 0;
}

.tree-container>.tree-list::before {
    display: none;
}

.tree-container>.tree-list>.tree-node::before {
    display: none;
}

/* --- Overlay / Tooltip --- */
.node-overlay {
    position: absolute;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    width: 280px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    /* Let pointer pass through to close it if needed, or handle exclusively via JS */
    transition: opacity 0.2s, transform 0.2s;
    opacity: 0;
    transform: translateY(5px);
}

.node-overlay:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

.node-overlay h4 {
    font-size: 0.875rem;
    color: white;
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.node-url {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    pointer-events: auto;
    /* Allow clicking link */
}

.node-url:hover {
    text-decoration: underline;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.meta-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.meta-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.meta-val {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    pointer-events: none;
}

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