/**
 * iMind Plugin - Fullscreen Mindmap
 * Mindmap feels like the background, no container
 * Dark/Light mode support with multiple color schemes
 */

/* === Base Setup === */
.imind-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

/* === Color Schemes === */

/* Dark Mode (Default) */
.imind-fullscreen[data-color-scheme="default"],
.imind-fullscreen[data-theme="dark"] {
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 50%, #16213e 100%);
}

/* Light Mode */
.imind-fullscreen[data-theme="light"] {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8eaf6 50%, #dfe3ee 100%);
}

/* Midnight Blue */
.imind-fullscreen[data-color-scheme="midnight"] {
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
}

/* Deep Purple */
.imind-fullscreen[data-color-scheme="purple"] {
    background: linear-gradient(135deg, #1a0033 0%, #2d1b4e 50%, #4a2c6f 100%);
}

/* Forest Green */
.imind-fullscreen[data-color-scheme="forest"] {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

/* Warm Sunset */
.imind-fullscreen[data-color-scheme="sunset"] {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* === Floating Header === */
.imind-floating-header {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    text-align: center;
    pointer-events: none;
    max-width: 90vw;
    transition: opacity 0.3s ease;
}

.imind-fullscreen[data-theme="light"] .imind-floating-header h1 {
    color: #1a1f2e;
    text-shadow: 0 2px 8px rgba(255, 255, 255, 0.8);
}

.imind-fullscreen[data-theme="dark"] .imind-floating-header h1,
.imind-floating-header h1 {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.imind-floating-header h1 {
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #42a5f5, #66bb6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.imind-subtitle {
    margin: 0.5rem 0 0;
    font-size: clamp(0.875rem, 2vw, 1rem);
    opacity: 0.7;
}

.imind-fullscreen[data-theme="light"] .imind-subtitle {
    color: #546e7a;
}

.imind-fullscreen[data-theme="dark"] .imind-subtitle,
.imind-subtitle {
    color: #b0bec5;
}

/* Auto-hide header when interacting */
.imind-fullscreen.interacting .imind-floating-header {
    opacity: 0.2;
}

/* === Floating Controls === */
.imind-floating-controls {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1002;
    display: flex;
    gap: 0.5rem;
    pointer-events: all;
}

.imind-floating-controls button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Dark theme button styles */
.imind-fullscreen[data-theme="dark"] .imind-floating-controls button,
.imind-floating-controls button {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.imind-fullscreen[data-theme="dark"] .imind-floating-controls button:hover,
.imind-floating-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(66, 165, 245, 0.3);
}

/* Light theme button styles */
.imind-fullscreen[data-theme="light"] .imind-floating-controls button {
    background: rgba(0, 0, 0, 0.05);
    color: #1a1f2e;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.imind-fullscreen[data-theme="light"] .imind-floating-controls button:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Theme toggle icon management */
.imind-fullscreen[data-theme="light"] .moon-icon {
    display: none;
}

.imind-fullscreen[data-theme="dark"] .sun-icon,
.sun-icon {
    display: none;
}

.imind-fullscreen[data-theme="light"] .sun-icon {
    display: block;
}

.imind-fullscreen[data-theme="dark"] .moon-icon,
.moon-icon {
    display: block;
}

/* === Floating Legend === */
.imind-legend {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 1001;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    transform: translateY(0);
    pointer-events: all;
}

/* Dark theme legend */
.imind-fullscreen[data-theme="dark"] .imind-legend,
.imind-legend {
    background: rgba(26, 31, 46, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Light theme legend */
.imind-fullscreen[data-theme="light"] .imind-legend {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Hide legend when attribute set */
.imind-legend[aria-hidden="true"] {
    transform: translateY(calc(100% + 2rem));
    opacity: 0;
    pointer-events: none;
}

.imind-legend h3 {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.imind-fullscreen[data-theme="light"] .imind-legend h3 {
    color: #546e7a;
}

.imind-fullscreen[data-theme="dark"] .imind-legend h3,
.imind-legend h3 {
    color: #b0bec5;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.legend-item:hover {
    transform: translateX(4px);
}

.imind-fullscreen[data-theme="light"] .legend-item span:last-child {
    color: #37474f;
}

.imind-fullscreen[data-theme="dark"] .legend-item span:last-child,
.legend-item span:last-child {
    color: #cfd8dc;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
    flex-shrink: 0;
}

.legend-item[data-status="not-started"] .legend-dot {
    background: #78909c;
}

.legend-item[data-status="in-progress"] .legend-dot {
    background: #ff9800;
}

.legend-item[data-status="completed"] .legend-dot {
    background: #42a5f5;
}

.legend-item[data-status="mastered"] .legend-dot {
    background: #66bb6a;
}

/* === Mindmap Canvas === */
.imind-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.imind-canvas svg {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
}

/* === SVG Node Styling === */

/* Dark theme nodes */
.imind-fullscreen[data-theme="dark"] .imind-canvas svg text,
.imind-canvas svg text {
    fill: rgba(255, 255, 255, 0.95) !important;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Light theme nodes */
.imind-fullscreen[data-theme="light"] .imind-canvas svg text {
    fill: rgba(26, 31, 46, 0.95) !important;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Dark theme links */
.imind-fullscreen[data-theme="dark"] .imind-canvas svg line,
.imind-fullscreen[data-theme="dark"] .imind-canvas svg path,
.imind-canvas svg line,
.imind-canvas svg path {
    stroke: rgba(255, 255, 255, 0.2) !important;
    stroke-width: 2px;
}

/* Light theme links */
.imind-fullscreen[data-theme="light"] .imind-canvas svg line,
.imind-fullscreen[data-theme="light"] .imind-canvas svg path {
    stroke: rgba(26, 31, 46, 0.25) !important;
    stroke-width: 2px;
}

/* Node interaction */
.imind-canvas .markmap-node {
    cursor: pointer;
    transition: filter 0.2s ease;
}

.imind-canvas .markmap-node:hover {
    filter: brightness(1.3) drop-shadow(0 0 12px currentColor);
}

.imind-canvas .markmap-node:active {
    filter: brightness(1.5);
}

/* === Loading State === */
.imind-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    pointer-events: none;
}

.loading-pulse {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #42a5f5, #66bb6a);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    box-shadow: 0 0 40px rgba(66, 165, 245, 0.4);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

.imind-loading p {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.imind-fullscreen[data-theme="light"] .imind-loading p {
    color: #546e7a;
}

.imind-fullscreen[data-theme="dark"] .imind-loading p,
.imind-loading p {
    color: #90a4ae;
}

/* Hide loading when loaded */
.imind-canvas.loaded .imind-loading {
    display: none;
}

/* === Progress Notification === */
.imind-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1003;
    padding: 1.25rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.125rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: notificationFade 3s ease forwards;
    pointer-events: none;
}

@keyframes notificationFade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* === Responsive Design === */
@media (max-width: 768px) {
    .imind-floating-header {
        top: 1rem;
    }

    .imind-floating-header h1 {
        font-size: 1.5rem;
    }

    .imind-subtitle {
        font-size: 0.875rem;
    }

    .imind-floating-controls {
        top: 1rem;
        right: 1rem;
        flex-direction: column;
    }

    .imind-legend {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: calc(100vw - 2rem);
    }

    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    .imind-fullscreen,
    .imind-floating-header,
    .imind-legend,
    .imind-floating-controls button,
    .legend-item,
    .imind-canvas .markmap-node {
        transition: none !important;
        animation: none !important;
    }

    .loading-pulse {
        animation: none !important;
    }
}

/* === Fullscreen Mode === */
.imind-fullscreen:fullscreen,
.imind-fullscreen:-webkit-full-screen,
.imind-fullscreen:-moz-full-screen {
    background: #0a0e1a;
}

.imind-fullscreen:fullscreen .imind-floating-controls,
.imind-fullscreen:-webkit-full-screen .imind-floating-controls,
.imind-fullscreen:-moz-full-screen .imind-floating-controls {
    top: 1rem;
    right: 1rem;
}

/* === Print Styles === */
@media print {
    .imind-floating-controls,
    .imind-legend {
        display: none;
    }

    .imind-fullscreen {
        background: white !important;
    }

    .imind-canvas svg text {
        fill: black !important;
    }

    .imind-canvas svg line,
    .imind-canvas svg path {
        stroke: #666 !important;
    }
}

/* === Focus Styles === */
.imind-floating-controls button:focus-visible {
    outline: 2px solid #42a5f5;
    outline-offset: 2px;
}

/* === Custom Scrollbar (for any overflow) === */
.imind-fullscreen::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.imind-fullscreen::-webkit-scrollbar-track {
    background: transparent;
}

.imind-fullscreen::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

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

.imind-fullscreen[data-theme="light"]::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

.imind-fullscreen[data-theme="light"]::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* === Branch Action Panel === */

.imind-branch-panel {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1100;
    width: 240px;
    background: rgba(15, 20, 35, 0.92);
    border: 1px solid rgba(66, 165, 245, 0.3);
    border-radius: 14px;
    padding: 20px 20px 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: panelSlideIn 0.2s ease-out;
}

@keyframes panelSlideIn {
    from { opacity: 0; transform: translateY(-50%) translateX(12px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

.imind-fullscreen[data-theme="light"] .imind-branch-panel {
    background: rgba(255, 255, 255, 0.93);
    border-color: rgba(30, 100, 200, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.imind-branch-panel[hidden] { display: none; }

.imind-branch-panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.imind-branch-panel-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}
.imind-fullscreen[data-theme="light"] .imind-branch-panel-close { color: rgba(0, 0, 0, 0.4); }
.imind-fullscreen[data-theme="light"] .imind-branch-panel-close:hover { color: black; background: rgba(0, 0, 0, 0.08); }

.imind-panel-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    line-height: 1;
}
.imind-panel-icon--unlocked { color: #66bb6a; }

.imind-panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e0e8ff;
    margin: 0 0 4px;
    line-height: 1.3;
}
.imind-fullscreen[data-theme="light"] .imind-panel-title { color: #1a237e; }

.imind-panel-label {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 12px;
}
.imind-fullscreen[data-theme="light"] .imind-panel-label { color: rgba(0, 0, 0, 0.45); }

.imind-panel-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #42a5f5;
    margin: 0 0 14px;
}

.imind-panel-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
    cursor: pointer;
}
.imind-panel-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.imind-panel-btn:active { transform: translateY(0); }

.imind-panel-btn--buy {
    background: linear-gradient(135deg, #1565c0, #42a5f5);
    color: white;
    margin-bottom: 8px;
}

.imind-panel-btn--start {
    background: linear-gradient(135deg, #2e7d32, #66bb6a);
    color: white;
}

.imind-panel-hint {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    margin: 0;
}
.imind-fullscreen[data-theme="light"] .imind-panel-hint { color: rgba(0, 0, 0, 0.3); }
