/**
 * Frontend styles for Iranian Math Tree
 * Matches the original design
 */

/* Fonts */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* Variables */
:root {
    --imt-color-red: #dc2626;
    --imt-color-yellow: #fbbf24;
    --imt-color-blue: #3b82f6;
    --imt-color-green: #34d399;
    --imt-color-purple: #8b5cf6;
    --imt-text-dark: #1f2937;
    --imt-text-light: #ffffff;
}

/* Container */
.imt-tree-wrapper {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    padding: 20px;
    background: #ffffff;
}

.imt-tree-wrapper[dir="ltr"] {
    font-family: 'Georgia', 'Times New Roman', serif;
}

/* Header */
.imt-header {
    text-align: center;
    margin-bottom: 24px;
}

.imt-title {
    font-size: 1.75rem;
    color: var(--imt-text-dark);
    margin: 0 0 5px 0;
}

.imt-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0;
}

/* Language Toggle */
.imt-lang-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.imt-lang-toggle-inner {
    background: white;
    border-radius: 50px;
    padding: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
}

.imt-lang-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    font-family: inherit;
    background: transparent;
    color: #64748b;
}

.imt-lang-btn.active {
    background: var(--imt-color-blue);
    color: white;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.imt-lang-btn:hover:not(.active) {
    background: #f1f5f9;
}

/* Tree Container */
.imt-tree-container {
    overflow-x: auto;
    padding: 10px 0 30px;
}

.imt-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: fit-content;
}

/* Layer Separator */
.imt-layer-separator {
    width: 100%;
    max-width: 900px;
    height: 1px;
    border-top: 2px dashed #cbd5e1;
    margin: 0;
}

/* Layer */
.imt-layer {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px 10px;
    max-width: 1000px;
}

/* Node */
.imt-node {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    white-space: nowrap;
}

.imt-node:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.imt-node.selected {
    transform: scale(1.05);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3), 0 8px 25px rgba(0,0,0,0.2);
}

.imt-node.highlight {
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.5);
    animation: imt-pulse-highlight 1.5s infinite;
}

@keyframes imt-pulse-highlight {
    0%, 100% { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0.25); }
}

/* Node Colors */
.imt-node-red {
    background: var(--imt-color-red);
    color: white;
    border-color: #b91c1c;
}

.imt-node-yellow {
    background: var(--imt-color-yellow);
    color: var(--imt-text-dark);
    border-color: #d97706;
}

.imt-node-blue {
    background: var(--imt-color-blue);
    color: white;
    border-color: #2563eb;
}

.imt-node-green {
    background: var(--imt-color-green);
    color: var(--imt-text-dark);
    border-color: #059669;
}

/* Color Legend */
.imt-color-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
    font-size: 13px;
}

.imt-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
}

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

.imt-legend-red { background: var(--imt-color-red); }
.imt-legend-yellow { background: var(--imt-color-yellow); }
.imt-legend-blue { background: var(--imt-color-blue); }
.imt-legend-green { background: var(--imt-color-green); }

/* Modal Overlay */
.imt-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 100000;
    padding: 60px 20px 20px;
}

.imt-modal-overlay.show {
    display: flex;
}

/* Modal */
.imt-modal {
    background: white;
    border-radius: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.imt-modal-header {
    padding: 20px 24px;
    color: white;
    flex-shrink: 0;
}

.imt-modal-header.imt-modal-header-red {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.imt-modal-header.imt-modal-header-yellow {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: var(--imt-text-dark);
}

.imt-modal-header.imt-modal-header-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.imt-modal-header.imt-modal-header-green {
    background: linear-gradient(135deg, #34d399, #059669);
    color: var(--imt-text-dark);
}

.imt-modal-header.imt-modal-header-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.imt-modal-name {
    font-size: 1.25rem;
    margin: 0 0 6px 0;
}

.imt-modal-subtitle {
    font-size: 13px;
    opacity: 0.85;
}

.imt-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.imt-modal-desc {
    color: #4b5563;
    line-height: 1.8;
    margin: 0;
}

.imt-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.imt-modal-btn {
    padding: 10px 18px;
    background: #e2e8f0;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    font-family: inherit;
}

.imt-modal-btn:hover {
    background: #cbd5e1;
}

.imt-modal-btn-primary {
    background: var(--imt-color-purple);
    color: white;
}

.imt-modal-btn-primary:hover {
    background: #7c3aed;
}

/* Links Modal Content */
.imt-links-section {
    margin-bottom: 20px;
}

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

.imt-links-section h4 {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.imt-links-section .icon {
    font-size: 16px;
}

.imt-link-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

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

.imt-link-item.clickable {
    cursor: pointer;
}

.imt-link-item.clickable:hover {
    background: #e0f2fe;
    transform: translateX(-4px);
}

[dir="ltr"] .imt-link-item.clickable:hover {
    transform: translateX(4px);
}

.imt-link-icon {
    font-size: 18px;
    margin-left: 12px;
    flex-shrink: 0;
}

[dir="ltr"] .imt-link-icon {
    margin-left: 0;
    margin-right: 12px;
}

.imt-link-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 12px;
    flex-shrink: 0;
}

[dir="ltr"] .imt-link-color {
    margin-left: 0;
    margin-right: 12px;
}

.imt-link-color-red { background: var(--imt-color-red); }
.imt-link-color-yellow { background: var(--imt-color-yellow); }
.imt-link-color-blue { background: var(--imt-color-blue); }
.imt-link-color-green { background: var(--imt-color-green); }
.imt-link-color-external { background: #94a3b8; }

.imt-link-content {
    flex: 1;
}

.imt-link-name {
    font-weight: 600;
    color: var(--imt-text-dark);
    font-size: 14px;
}

.imt-link-relation {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.imt-link-arrow {
    color: #94a3b8;
    font-size: 18px;
}

.imt-link-item.clickable:hover .imt-link-arrow {
    color: var(--imt-color-blue);
}

.imt-no-links {
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
    padding: 10px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .imt-node {
        font-size: 12px;
        padding: 10px 16px;
    }

    .imt-modal {
        max-width: 100%;
    }

    .imt-modal-footer {
        justify-content: center;
    }
}
