/* Sequoia3 - Apple-inspired Modern Tree Manager Application Styles */

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #1d1d1f;
    line-height: 1.5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Tree Node Styles - Apple-inspired */
.tree-node {
    position: relative;
    margin: 1px 0;
    border-radius: 8px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-node:hover {
    background-color: rgba(0, 122, 255, 0.08);
    /* transform: translateX(2px); */
}

/* Tree Loading and Error States */
.tree-loading {
    padding: 8px 16px;
    color: #6b7280;
    font-size: 0.875rem;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.tree-error {
    padding: 8px 16px;
    color: #dc2626;
    font-size: 0.875rem;
    background-color: #fef2f2;
    border-radius: 4px;
    margin: 4px 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
}

.tree-node-content:hover {
    background-color: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.2);
    /* transform: translateX(2px); */
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

.tree-node-content.selected {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15), rgba(0, 122, 255, 0.1));
    border-color: rgba(0, 122, 255, 0.3);
    color: #007AFF;
    box-shadow: 0 2px 12px rgba(0, 122, 255, 0.2);
    font-weight: 600;
}

.tree-node-content.dragging {
    opacity: 0.6;
    transform: rotate(2deg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.tree-node-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
    color: #8e8e93;
    transition: color 0.15s ease;
}

.tree-node-content.selected .tree-node-icon {
    color: #007AFF;
}

.tree-node-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1d1d1f;
}

.tree-node-content.selected .tree-node-name {
    color: #007AFF;
    font-weight: 600;
}

/* Restricted visibility indicator: dashed underline */
.tree-node-name.restricted {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 2px;
}

.tree-node-children {
    margin-left: 16px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    padding-left: 8px;
    position: relative;
}

.tree-node-children::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
}

.tree-node-children.collapsed {
    display: none;
}

.tree-node-toggle {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #8e8e93;
    border-radius: 3px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-node-toggle.togglehidden {
    visibility: hidden;
}

.tree-node-toggle:hover {
    color: #007AFF;
    background-color: rgba(0, 122, 255, 0.1);
}

.tree-node-toggle.expanded {
    transform: rotate(90deg);
    color: #007AFF;
}

/* Context Menu - Apple Style */
.context-menu {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 1000;
    min-width: 200px;
    display: none;
    overflow: hidden;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background-color: rgba(0, 122, 255, 0.1);
    color: #007AFF;
}

.context-menu-item.danger {
    color: #ff3b30;
}

.context-menu-item.danger:hover {
    background-color: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.context-menu-item i {
    width: 16px;
    margin-right: 10px;
    text-align: center;
}

.context-menu-separator {
    height: 1px;
    background-color: #e5e7eb;
    margin: 4px 0;
}

.context-menu-item.highlighted {
    background-color: #f1f5f9;
    color: #1f2937;
}

/* Mobile Context Menu Improvements */
@media (max-width: 768px) {
    .context-menu {
        min-width: 200px;
        max-width: 90vw;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .context-menu-item {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 44px; /* iOS touch target size */
    }
    
    .context-menu-item i {
        width: 20px;
        margin-right: 12px;
        font-size: 16px;
    }
}

/* Drag and Drop */
.drag-over {
    background-color: #dbeafe !important;
    border: 2px dashed #3b82f6 !important;
    border-radius: 8px;
}

.drag-placeholder {
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    margin: 2px 0;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notification Styles - Apple Design */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 1001;
    display: flex;
    align-items: center;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
    font-weight: 500;
}

.notification.success {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.2);
    color: #1E7E34;
}

.notification.error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: #B91C1C;
}

.notification.info {
    background: rgba(0, 122, 255, 0.1);
    border: 1px solid rgba(0, 122, 255, 0.2);
    color: #004499;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Form Elements - Apple Style */
.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    background: rgba(255, 255, 255, 0.95);
}

/* Button Styles - Apple Design */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 6px;
    backdrop-filter: blur(10px);
}

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

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #007AFF, #0056CC);
    border-color: #007AFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056CC, #004499);
    border-color: #0056CC;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
}

.btn-secondary {
    color: #1d1d1f;
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    color: #007AFF;
    background: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.2);
}

.btn-success {
    color: #fff;
    background: linear-gradient(135deg, #34C759, #28A745);
    border-color: #34C759;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #28A745, #1E7E34);
    border-color: #28A745;
    box-shadow: 0 4px 15px rgba(52, 199, 89, 0.4);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #FF3B30, #DC2626);
    border-color: #FF3B30;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    border-color: #DC2626;
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.4);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .tree-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .tree-panel {
        width: 100%;
        height: 300px;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .tree-panel-content {
        max-height: 250px;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    /* Mobile menu styles */
    .mobile-menu-toggle {
        display: block;
    }
    
    .tree-panel {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .tree-panel.open {
        transform: translateX(0);
    }
    
    .mobile-overlay {
        display: block;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 12px 16px;
    }
    
    .app-header h1 {
        font-size: 1.25rem;
    }
    
    .tree-panel-header {
        padding: 12px 16px;
    }
    
    .content-header {
        padding: 12px 16px;
    }
    
    .content-body {
        padding: 16px;
    }
    
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    /* Mobile menu button positioning */
    .mobile-menu-toggle {
        top: 12px;
        left: 12px;
    }
}

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

.text-muted {
    color: #6b7280;
}

.text-center {
    text-align: center;
}

.mb-3 {
    margin-bottom: 1rem;
}

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

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Focus States for Accessibility */
.tree-node-content:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Additional Apple-style enhancements */
.tree-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
    overflow: hidden;
}

.tree-panel-content {
    background: transparent;
}

/* Enhanced glass morphism effects */
.glass-effect {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Improved focus states for accessibility */
.tree-node-content:focus {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
    background-color: rgba(0, 122, 255, 0.1);
}

.btn:focus {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Smooth animations for better UX */
* {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
        color: #f5f5f7;
    }
    
    .tree-node-content:hover {
        background-color: rgba(0, 122, 255, 0.1);
    }
    
    .tree-node-content.selected {
        background: linear-gradient(135deg, rgba(0, 122, 255, 0.2), rgba(0, 122, 255, 0.1));
        color: #007AFF;
    }
    
    .tree-panel {
        background: rgba(28, 28, 30, 0.9);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
}