/* Parann File Browser Styles */

/* ── Layout ── */
.fb-container {
    display: flex;
    min-height: calc(100vh - 80px);
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 0;
}

.fb-sidebar {
    width: 300px;
    min-width: 260px;
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1.5rem 1.5rem 0;
    overflow-y: auto;
    flex-shrink: 0;
}

.fb-main {
    flex: 1;
    padding: 1.5rem 0 1.5rem 1.5rem;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Selectors ── */
.fb-selector-group {
    margin-bottom: 1.25rem;
}

.fb-selector-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.fb-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23AAAAAA' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.fb-select:hover,
.fb-select:focus {
    border-color: var(--border-hover);
    outline: none;
}

.fb-select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── Sidebar Panels ── */
.fb-panel {
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.fb-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.fb-panel-header:hover {
    background: var(--bg-tertiary);
}

.fb-panel-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fb-panel-toggle {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.fb-panel-toggle.collapsed {
    transform: rotate(-90deg);
}

.fb-panel-body {
    padding: 0 1rem 1rem;
}

.fb-panel-body.collapsed {
    display: none;
}

/* ── Usage Bar ── */
.fb-usage-bar-container {
    margin-top: 0.5rem;
}

.fb-usage-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.375rem;
}

.fb-usage-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.fb-usage-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    background: var(--accent-green);
}

.fb-usage-fill.warning {
    background: #f59e0b;
}

.fb-usage-fill.danger {
    background: #ef4444;
}

.fb-usage-info {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.375rem;
}

/* ── Breadcrumbs ── */
.fb-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.fb-breadcrumb-item {
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
}

.fb-breadcrumb-item:hover {
    color: var(--accent-green);
    background: rgba(176, 255, 48, 0.08);
}

.fb-breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
    cursor: default;
}

.fb-breadcrumb-item.active:hover {
    background: none;
}

.fb-breadcrumb-sep {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    user-select: none;
}

/* ── Header Row ── */
.fb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.fb-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ── Directory Listing Table ── */
.fb-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.fb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.fb-table thead th {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.625rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.fb-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
    cursor: pointer;
}

.fb-table tbody tr:last-child {
    border-bottom: none;
}

.fb-table tbody tr:hover {
    background: rgba(176, 255, 48, 0.04);
}

.fb-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.fb-table tbody tr:nth-child(even):hover {
    background: rgba(176, 255, 48, 0.04);
}

.fb-table td {
    padding: 0.625rem 1rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.fb-table td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.fb-file-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fb-file-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.fb-dir-icon {
    color: var(--accent-green);
}

.fb-hash {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-actions {
    display: flex;
    gap: 0.375rem;
}

.fb-action-btn {
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.fb-action-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
    background: rgba(176, 255, 48, 0.08);
}

.fb-action-btn.danger:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* ── Upload Zone ── */
.fb-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.fb-upload-zone:hover {
    border-color: var(--accent-green);
    background: rgba(176, 255, 48, 0.04);
}

.fb-upload-zone.dragover {
    border-color: var(--accent-green);
    background: rgba(176, 255, 48, 0.08);
    box-shadow: 0 0 20px rgba(176, 255, 48, 0.15);
}

.fb-upload-zone-icon {
    font-size: 2rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.fb-upload-zone-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.fb-upload-zone-hint {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

.fb-upload-input {
    display: none;
}

.fb-upload-path-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    align-items: center;
}

.fb-upload-path-row label {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.fb-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.fb-input:focus {
    border-color: var(--accent-green);
    outline: none;
}

.fb-input::placeholder {
    color: var(--text-tertiary);
}

/* ── Upload Progress ── */
.fb-upload-progress {
    margin-top: 1rem;
    display: none;
}

.fb-upload-progress.active {
    display: block;
}

.fb-upload-filename {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.fb-upload-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.fb-upload-bar-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 2px;
    width: 0;
    transition: width 0.3s ease;
}

/* ── Upload Result ── */
.fb-upload-result {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(176, 255, 48, 0.06);
    border: 1px solid rgba(176, 255, 48, 0.2);
    border-radius: 6px;
    display: none;
}

.fb-upload-result.active {
    display: block;
}

.fb-upload-result-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-green);
    margin-bottom: 0.5rem;
}

.fb-upload-result-item {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.fb-upload-result-item strong {
    color: var(--text-primary);
}

.fb-upload-result-hash {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    font-size: 0.8125rem;
    color: var(--accent-green);
    word-break: break-all;
}

/* ── Member / API Key Management ── */
.fb-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 0.5rem;
}

.fb-list-item:last-child {
    border-bottom: none;
}

.fb-list-item-info {
    flex: 1;
    min-width: 0;
}

.fb-list-item-name {
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-list-item-detail {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-add-row {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.fb-add-row .fb-input {
    min-width: 0;
}

.fb-add-row .fb-select {
    width: auto;
    min-width: 90px;
}

.fb-btn-sm {
    padding: 0.375rem 0.625rem;
    background: var(--accent-green);
    color: #000;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.fb-btn-sm:hover {
    background: var(--accent-green-light);
    transform: translateY(-1px);
}

.fb-btn-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.fb-btn-sm.danger {
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border-color);
}

.fb-btn-sm.danger:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* ── Scopes checkboxes ── */
.fb-scopes-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.375rem 0;
}

.fb-scope-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.fb-scope-label input[type="checkbox"] {
    accent-color: var(--accent-green);
    width: 14px;
    height: 14px;
}

/* ── Chain / Provenance Panel ── */
.fb-chain-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fb-chain-stat:last-child {
    border-bottom: none;
}

.fb-chain-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.fb-chain-stat-value {
    font-size: 0.8125rem;
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Provenance Detail Modal ── */
.fb-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.fb-modal-overlay.active {
    display: flex;
}

.fb-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.fb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.fb-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fb-modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s ease;
}

.fb-modal-close:hover {
    color: var(--text-primary);
}

.fb-modal-body {
    padding: 1.25rem;
}

.fb-provenance-item {
    margin-bottom: 1rem;
}

.fb-provenance-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.fb-provenance-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-all;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    background: var(--bg-tertiary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.fb-provenance-value.highlight {
    color: var(--accent-green);
    border-color: rgba(176, 255, 48, 0.2);
    background: rgba(176, 255, 48, 0.06);
}

/* ── Loading / Empty / Error states ── */
.fb-loading,
.fb-empty,
.fb-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.fb-error {
    color: #ef4444;
}

.fb-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: fb-spin 0.6s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

@keyframes fb-spin {
    to { transform: rotate(360deg); }
}

/* ── Notification Toast ── */
.fb-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 2000;
    max-width: 400px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.fb-toast.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.fb-toast.success {
    background: rgba(176, 255, 48, 0.1);
    border: 1px solid rgba(176, 255, 48, 0.3);
    color: var(--accent-green);
}

.fb-toast.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.fb-toast.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

/* ── API Key revealed ── */
.fb-key-reveal {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(176, 255, 48, 0.06);
    border: 1px solid rgba(176, 255, 48, 0.2);
    border-radius: 6px;
}

.fb-key-reveal-label {
    font-size: 0.6875rem;
    color: var(--accent-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.fb-key-reveal-value {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    font-size: 0.8125rem;
    color: var(--text-primary);
    word-break: break-all;
    cursor: pointer;
}

.fb-key-reveal-hint {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: 0.375rem;
}

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

    .fb-sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem 0;
    }

    .fb-main {
        padding: 1rem 0;
    }

    .fb-table td,
    .fb-table thead th {
        padding: 0.5rem 0.625rem;
    }

    .fb-hash {
        max-width: 100px;
    }
}

@media (max-width: 600px) {
    .fb-upload-path-row {
        flex-direction: column;
        align-items: stretch;
    }

    .fb-add-row {
        flex-direction: column;
    }

    .fb-add-row .fb-select {
        width: 100%;
    }

    .fb-breadcrumbs {
        font-size: 0.8125rem;
    }

    .fb-actions {
        flex-direction: column;
    }
}

/* ── Chain Alert Banner ── */
.alert-banner {
    background-color: #fff3cd;
    border-bottom: 1px solid #ffc107;
    padding: 10px 20px;
    position: relative;
    z-index: 100;
}

.alert-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1200px;
    margin: 0 auto;
}

.alert-banner-icon {
    font-size: 1.2em;
    color: #856404;
}

.alert-banner-link {
    color: #856404;
    text-decoration: underline;
    margin-left: auto;
}

.alert-banner-dismiss {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: #856404;
    padding: 0 5px;
}
