/**
 * Modern Folder Tree Styles
 * Bootstrap 4 Enterprise Design System
 * Follows design standards from CLAUDE.md
 */

/* ========================================
   Container
   ======================================== */
.modern-folder-tree {
    background: #fff;
    border-radius: var(--radius-lg, 0.75rem);
}

/* ========================================
   Search Box
   ======================================== */
.mft-search-box {
    padding: 0;
}

.mft-search-box .input-group {
    margin-bottom: 0.75rem;
}

.mft-search-box .input-group-text {
    background: #fff;
    border-right: 0;
    padding-left: 0.75rem;
}

.mft-search-input {
    border-left: 0 !important;
    font-size: 0.875rem;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mft-search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mft-clear-search button {
    background: #fff;
    border-color: #dee2e6;
    color: #6c757d;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mft-clear-search button:hover {
    background: #f8f9fa;
    color: #495057;
}

/* ========================================
   Breadcrumb
   ======================================== */
.mft-breadcrumb {
    margin-bottom: 0.5rem;
}

.mft-breadcrumb .breadcrumb {
    background: transparent;
    padding: 0.5rem 0;
    margin-bottom: 0;
    font-size: 0.8125rem;
}

.mft-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-size: 1rem;
    color: #6c757d;
}

.mft-breadcrumb .breadcrumb-item a {
    color: #2563eb;
    text-decoration: none;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mft-breadcrumb .breadcrumb-item a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* ========================================
   Tree Container
   ======================================== */
.mft-tree-container {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md, 0.5rem);
    background: #fff;
}

/* Custom scrollbar */
.mft-tree-container::-webkit-scrollbar {
    width: 6px;
}

.mft-tree-container::-webkit-scrollbar-track {
    background: transparent;
}

.mft-tree-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.mft-tree-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========================================
   Folder Items
   ======================================== */
.mft-folder-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    min-height: 48px; /* Fixed height */
    border: 0;
    border-radius: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: #1f2937;
    background: #fff;
    transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

/* Remove default list group borders */
.mft-tree-container .list-group-item:first-child {
    border-top-left-radius: var(--radius-md, 0.5rem);
    border-top-right-radius: var(--radius-md, 0.5rem);
}

.mft-tree-container .list-group-item:last-child {
    border-bottom-left-radius: var(--radius-md, 0.5rem);
    border-bottom-right-radius: var(--radius-md, 0.5rem);
}

/* Hover state */
.mft-folder-item:hover {
    background-color: #f9fafb;
    color: #2563eb;
}

/* Active/Selected state */
.mft-folder-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    font-weight: 600;
}

.mft-folder-item.active:hover {
    background: rgba(37, 99, 235, 0.15);
}

/* Focus state (keyboard navigation) */
.mft-folder-item:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px #2563eb;
    z-index: 1;
}

/* ========================================
   Toggle Button
   ======================================== */
.mft-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mft-toggle-btn:hover {
    transform: scale(1.1);
}

.mft-chevron {
    font-size: 0.75rem;
    color: #6b7280;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expanded state */
.mft-chevron.fa-chevron-down {
    transform: rotate(0deg);
    color: #2563eb;
}

/* Collapsed state */
.mft-chevron.fa-chevron-right {
    transform: rotate(0deg);
}

/* ========================================
   Folder Name
   ======================================== */
.mft-folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Search highlight */
.mft-highlight {
    background-color: #fef08a;
    color: #854d0e;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-weight: 600;
}

/* Search match item */
.mft-folder-item.mft-search-match {
    background-color: rgba(250, 204, 21, 0.1);
}

/* ========================================
   Children Container
   ======================================== */
.mft-children-container {
    background: #fafafa;
}

.mft-children-container .mft-folder-item {
    background: transparent;
}

.mft-children-container .mft-folder-item:hover {
    background: rgba(249, 250, 251, 0.8);
}

.mft-children-container .mft-folder-item.active {
    background: rgba(37, 99, 235, 0.08);
}

/* Nested indentation - handled via inline styles in JS */

/* ========================================
   Empty State
   ======================================== */
.mft-tree-container .text-muted {
    color: #9ca3af !important;
}

/* ========================================
   Loading State
   ======================================== */
.mft-tree-container .fa-spinner {
    color: #2563eb;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 576px) {
    .mft-tree-container {
        max-height: 240px;
    }

    .mft-folder-item {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem;
        min-height: 44px; /* Slightly smaller on mobile */
    }

    .mft-breadcrumb .breadcrumb {
        font-size: 0.75rem;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .modern-folder-tree {
        background: #1f2937;
    }

    .mft-tree-container {
        background: #1f2937;
        border-color: #374151;
    }

    .mft-search-box .input-group-text,
    .mft-search-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .mft-folder-item {
        color: #f9fafb;
        background: transparent;
    }

    .mft-folder-item:hover {
        background: rgba(75, 85, 99, 0.3);
    }

    .mft-folder-item.active {
        background: rgba(37, 99, 235, 0.2);
        color: #93c5fd;
    }

    .mft-breadcrumb .breadcrumb-item {
        color: #d1d5db;
    }

    .mft-breadcrumb .breadcrumb-item a {
        color: #93c5fd;
    }

    .mft-children-container {
        background: rgba(0, 0, 0, 0.1);
    }
}

/* ========================================
   File Share Dialog Enhancements
   ======================================== */

/* Nav Pills for Link Types */
#shareLinkTabs .nav-link {
    border-radius: var(--radius-md, 0.5rem);
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#shareLinkTabs .nav-link:hover {
    background: #f9fafb;
    color: #2563eb;
}

#shareLinkTabs .nav-link.active {
    background: #2563eb !important;
    color: #fff !important;
    border-color: #2563eb !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

#shareLinkTabs .nav-link.active:hover {
    background: #1d4ed8 !important;
    color: #fff !important;
}

#shareLinkTabs .nav-link i {
    font-size: 1rem;
    color: inherit;
}

#shareLinkTabs .nav-link span {
    color: inherit;
}

/* Format Selection Button Group */
.btn-group-sm .btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    font-weight: 500;
}

/* Link Area Textarea */
#link_area {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md, 0.5rem);
    resize: vertical;
    min-height: 120px;
}

#link_area:focus {
    background: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Password Visibility Toggle Card */
.bg-light.rounded {
    border: 1px solid #e5e7eb;
}

/* ========================================
   Accessibility Improvements
   ======================================== */
.mft-folder-item[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .mft-folder-item:focus {
        box-shadow: inset 0 0 0 3px #000;
    }

    .mft-folder-item.active {
        box-shadow: inset 4px 0 0 #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mft-folder-item,
    .mft-toggle-btn,
    .mft-chevron,
    .mft-search-input {
        transition: none;
    }
}
