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

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

:root {
    --color-thesis: #FFD700;
    --color-foundational: #4A90E2;
    --color-practical: #7ED321;
    --color-support: #50C878;
    --color-attack: #E74C3C;
    --color-bg: #f8f9fa;
    --color-sidebar: #2c3e50;
    --color-card: #fafafa;
    --color-text: #1a1a2e;
    --color-text-muted: #6c757d;
    --color-border: #dee2e6;
    --color-text-light: #ecf0f1;
    --color-text-muted-light: #bdc3c7;
    --font-family: 'Vazirmatn', sans-serif;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 15px 40px rgba(0, 0, 0, 0.2);
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    direction: rtl;
    text-align: right;
    overflow: hidden;
    height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--color-sidebar);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-light);
}

.refresh-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-light);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--color-foundational);
    box-shadow: var(--shadow-md);
}

.refresh-btn svg {
    transition: transform 0.3s ease;
}

.refresh-btn:hover svg {
    transform: rotate(180deg);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.file-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.file-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.file-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--color-foundational);
    transform: translateX(-4px);
    box-shadow: var(--shadow-md);
}

.file-item.active {
    background-color: rgba(74, 144, 226, 0.2);
    border-color: var(--color-foundational);
    box-shadow: var(--shadow-lg);
}

.file-item-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--color-text-light);
}

.file-item-meta {
    font-size: 12px;
    color: var(--color-text-muted-light);
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted-light);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.action-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-light);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.action-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--color-foundational);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.action-btn svg {
    transition: transform 0.3s ease;
}

.action-btn:hover svg {
    transform: scale(1.1);
}

/* Custom Tooltips for Action Buttons */
.action-btn {
    position: relative;
}

.action-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-sidebar);
    color: var(--color-text-light);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-family);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    margin-bottom: 8px;
}

.action-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chart Header */
.chart-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-bg);
}

.chart-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text);
}

.breadcrumb {
    font-size: 14px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-item {
    cursor: pointer;
    transition: color 0.2s ease;
}

.breadcrumb-item:hover {
    color: var(--color-foundational);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--color-text-muted);
}

/* Chart Container */
.chart-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chart-wrapper {
    width: 100%;
    height: 100%;
    display: none;
    position: relative;
}

.chart-wrapper.active {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sunburst-chart {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.sunburst-chart path {
    transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease;
}

.sunburst-chart path:hover {
    transform: scale(1.02);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    gap: 20px;
}

.empty-state svg {
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 15px 30px;
    background-color: #f0f4f8;
    border-top: 1px solid var(--color-border);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-thesis {
    background-color: var(--color-thesis);
}

.legend-foundational {
    background-color: var(--color-foundational);
}

.legend-practical {
    background-color: var(--color-practical);
}

.legend-support {
    background-color: var(--color-support);
}

.legend-attack {
    background-color: var(--color-attack);
}

/* Detail Card (Tooltip) */
.detail-card {
    position: fixed;
    background-color: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    max-width: 350px;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    direction: rtl;
    text-align: right;
}

.detail-card.border-support {
    border-color: var(--color-support);
}

.detail-card.border-attack {
    border-color: var(--color-attack);
}

.detail-card.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.detail-type {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-type.thesis {
    background-color: rgba(255, 215, 0, 0.2);
    color: var(--color-thesis);
    border: 1px solid var(--color-thesis);
}

.detail-type.foundational {
    background-color: rgba(74, 144, 226, 0.2);
    color: var(--color-foundational);
    border: 1px solid var(--color-foundational);
}

.detail-type.practical {
    background-color: rgba(126, 211, 33, 0.2);
    color: var(--color-practical);
    border: 1px solid var(--color-practical);
}

.detail-speaker {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.detail-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.5;
    color: var(--color-text);
}

.detail-description {
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-text-muted);
    margin-bottom: 15px;
}

.detail-relation {
    display: none;
}

.detail-reasoning {
    display: none;
}

.detail-quote {
    font-size: 12px;
    color: var(--color-text-muted);
    padding: 10px 14px;
    background-color: rgba(0, 0, 0, 0.03);
    border-right: 3px solid var(--color-foundational);
    border-radius: 0 6px 6px 0;
    margin-bottom: 15px;
    font-style: italic;
    line-height: 1.6;
}

.detail-score {
    display: none;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--color-sidebar);
    color: var(--color-text-light);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-size: 14px;
}

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

.score-label {
    font-size: 12px;
    color: var(--color-text-muted);
}

.score-bar {
    flex: 1;
    height: 6px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-foundational), var(--color-practical));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.score-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    min-width: 35px;
    text-align: left;
}

/* Foundational Marker */
.foundational-marker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.foundational-marker svg {
    width: 14px;
    height: 14px;
    fill: var(--color-foundational);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 200px;
        order: 2;
    }

    .main-content {
        order: 1;
    }

    .legend {
        padding: 10px 15px;
        gap: 10px;
    }

    .legend-item {
        font-size: 11px;
    }

    .detail-card {
        max-width: 280px;
        padding: 15px;
    }
}
