/* File Tree Builder Styles */
:root {
    --ft-bg: #1e1e2e;
    --ft-bg-hover: #2a2a3c;
    --ft-border: #3f3f55;
    --ft-text: #e0e0e0;
    --ft-text-muted: #a0a0a0;
    --ft-primary: #8b5cf6;
    --ft-danger: #ef4444;
    --ft-success: #10b981;
    --ft-folder: #fbbf24;
    --ft-file: #60a5fa;
}

.file-tree-wrapper {
    background: #1e1e2e85;
    border: 1px solid var(--ft-border);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--ft-text);
    font-family: 'Vazirmatn', sans-serif;
    margin: 2rem 0;
    direction: rtl;
}

.ft-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--ft-border);
    padding-bottom: 1rem;
}

.ft-btn {
    background: var(--ft-bg-hover);
    border: 1px solid var(--ft-border);
    color: var(--ft-text);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.ft-btn:hover {
    background: var(--ft-border);
    color: white;
}

.ft-btn.primary {
    background: var(--ft-primary);
    border-color: var(--ft-primary);
    color: white;
}

.ft-btn.primary:hover {
    filter: brightness(1.1);
}

/* Tree Structure */
.ft-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ft-node {
    margin-bottom: 2px;
}

.ft-row {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.ft-row:hover {
    background: var(--ft-bg-hover);
}

.ft-row.selected {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--ft-primary);
}

.ft-indent {
    width: 20px;
    height: 100%;
    display: inline-block;
    flex-shrink: 0;
    border-right: 1px dashed var(--ft-border);
    margin-left: 5px;
}

.ft-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ft-text-muted);
    transition: transform 0.2s;
}

.ft-toggle:hover {
    color: white;
}

.ft-toggle.expanded {
    transform: rotate(-90deg); /* RTL specific rotation */
}

.ft-icon {
    width: 24px;
    height: 24px;
    margin-left: 0.75rem;
    flex-shrink: 0;
}

.ft-icon.folder {
    color: var(--ft-folder);
}

.ft-icon.file {
    color: var(--ft-file);
}

.ft-content {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0; /* Important for flex child truncation */
}

.ft-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 60%;
}

.ft-meta {
    font-size: 0.8rem;
    color: var(--ft-text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

@media (max-width: 600px) {
    .ft-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
    
    .ft-name {
        max-width: 100%;
        font-size: 0.95rem;
    }
    
    .ft-meta {
        font-size: 0.75rem;
        max-width: 100%;
    }
    
    .ft-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ft-btn {
        justify-content: center;
    }
    
    #ft-export-json {
        margin-right: 0 !important;
    }
}

/* Inline Edit Form */
.ft-edit-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
}

.ft-input {
    background: var(--ft-bg);
    border: 1px solid var(--ft-border);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 100%;
    /* max-width: 200px; Remove max-width for better modal layout */
}

.ft-input:focus {
    outline: none;
    border-color: var(--ft-primary);
}

.ft-select {
    background: var(--ft-bg);
    border: 1px solid var(--ft-border);
    color: white;
    padding: 0.25rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Actions */
.ft-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.ft-row:hover .ft-actions {
    opacity: 1;
}

.ft-action-btn {
    background: transparent;
    border: none;
    color: var(--ft-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.ft-action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.ft-action-btn.delete:hover {
    color: var(--ft-danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Properties Panel */
.ft-properties {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ft-border);
    display: none;
}

.ft-properties.active {
    display: block;
    animation: slideDown 0.3s ease;
}

.ft-prop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.ft-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ft-label {
    font-size: 0.85rem;
    color: var(--ft-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .ft-actions {
        opacity: 1; /* Always show on mobile */
    }
    
    .ft-row {
        flex-wrap: wrap;
    }
    
    .ft-actions {
        margin-right: auto; /* Push to left in RTL */
    }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ft-error-msg {
    color: var(--ft-danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: none;
}

/* Modal Styles */
.ft-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.ft-modal.show {
    display: flex;
}

.ft-modal-content {
    background-color: var(--ft-bg);
    border: 1px solid var(--ft-border);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.ft-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ft-text);
}

.ft-modal-close {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--ft-text-muted);
    cursor: pointer;
    line-height: 1;
}

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

.ft-modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ft-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--ft-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
