/* ===== Documents & File Library CSS ===== */
/* Design System: "Refined Industrial" - Copper=#c17f59 */

/* ===== Container ===== */
.documents-container {
    padding: 0 24px 32px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== Tabs ===== */
.documents-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.documents-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.documents-tab:hover {
    color: var(--text-primary);
}

.documents-tab.active {
    color: var(--copper);
    border-bottom-color: var(--copper);
    font-weight: 600;
}

.documents-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.documents-tab-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    line-height: 1.5;
}

.documents-tab.active .documents-tab-badge {
    background: rgba(193, 127, 89, 0.15);
    color: var(--copper);
}

/* ===== Upload Toolbar ===== */
.documents-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.documents-toolbar-spacer {
    flex: 1;
}

.documents-search {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 320px;
}

.documents-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.documents-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.documents-search input:focus {
    border-color: var(--copper);
}

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

/* ===== Upload Dropzone ===== */
.upload-dropzone {
    display: none;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.upload-dropzone.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
    border-color: var(--copper);
    background: rgba(193, 127, 89, 0.05);
}

.upload-dropzone-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(193, 127, 89, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--copper);
}

.upload-dropzone-icon svg {
    width: 22px;
    height: 22px;
}

.upload-dropzone-title {
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-dropzone-sub {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.upload-dropzone-btn {
    margin-top: 4px;
    padding: 7px 16px;
    background: var(--copper);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.upload-dropzone-btn:hover {
    background: var(--copper-dark);
}

/* ===== Two-Panel Layout ===== */
.documents-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* ===== Folder Tree (Left Panel) ===== */
.folder-tree {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-self: start;
}

.folder-tree-header {
    padding: 6px 10px 10px;
    font-family: 'Sora', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    user-select: none;
    position: relative;
}

.folder-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.folder-item.active {
    background: rgba(193, 127, 89, 0.1);
    color: var(--copper);
    font-weight: 600;
}

.folder-item.active .folder-icon {
    color: var(--copper);
}

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

.folder-item:hover .folder-icon {
    color: var(--text-secondary);
}

.folder-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item-count {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    flex-shrink: 0;
    line-height: 1.5;
}

.folder-item.active .folder-item-count {
    background: rgba(193, 127, 89, 0.2);
    color: var(--copper-dark);
}

/* ===== File List (Right Panel) ===== */
.file-list-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.file-list-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.file-list-title {
    font-family: 'Sora', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.file-list-count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-left: 6px;
}

.file-view-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.file-view-btn {
    padding: 5px 8px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.file-view-btn:hover {
    color: var(--text-primary);
}

.file-view-btn.active {
    background: var(--bg-white);
    color: var(--copper);
    box-shadow: var(--shadow-sm);
}

.file-view-btn svg {
    width: 15px;
    height: 15px;
}

/* ===== File Grid ===== */
.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.file-list.list-mode {
    grid-template-columns: 1fr;
    gap: 6px;
}

/* ===== File Card ===== */
.file-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.file-card:hover {
    border-color: var(--copper-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.file-list.list-mode .file-card {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 14px;
}

.file-card-icon-area {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.file-list.list-mode .file-card-icon-area {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
}

/* File type icon colors */
.file-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

.file-type-icon.type-pdf {
    background: rgba(201, 97, 90, 0.1);
    color: #c9615a;
}

.file-type-icon.type-image {
    background: rgba(74, 123, 189, 0.1);
    color: #4a7bbd;
}

.file-type-icon.type-doc {
    background: rgba(90, 154, 110, 0.1);
    color: #5a9a6e;
}

.file-type-icon svg {
    width: 22px;
    height: 22px;
}

.file-list.list-mode .file-type-icon svg {
    width: 18px;
    height: 18px;
}

.file-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-list.list-mode .file-card-body {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.file-card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.file-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.file-list.list-mode .file-card-meta {
    margin-left: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.file-meta-item {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.file-meta-item svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.file-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
}

/* ===== Signature Badges ===== */
.signature-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.5;
    flex-shrink: 0;
}

.signature-badge svg {
    width: 11px;
    height: 11px;
}

.signature-badge.pending {
    background: var(--amber-light);
    color: var(--amber);
}

.signature-badge.viewed {
    background: var(--blue-light);
    color: var(--blue);
}

.signature-badge.signed {
    background: var(--green-light);
    color: var(--green);
}

/* ===== File Empty State ===== */
.file-list-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 12px;
    text-align: center;
    color: var(--text-tertiary);
}

.file-list-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.file-list-empty-icon svg {
    width: 22px;
    height: 22px;
}

.file-list-empty-title {
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.file-list-empty-sub {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    max-width: 260px;
    line-height: 1.5;
}

/* ===== File Detail Panel (Slide-out) ===== */
.file-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.file-detail-overlay.open {
    opacity: 1;
    visibility: visible;
}

.file-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background: var(--bg-white);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
}

.file-detail-panel.open {
    transform: translateX(0);
}

.file-detail-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.file-detail-badge {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-family: 'Sora', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.file-detail-title {
    flex: 1;
    font-family: 'Sora', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-detail-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.file-detail-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.file-detail-close svg {
    width: 16px;
    height: 16px;
}

.file-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* File preview area */
.file-detail-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.file-detail-preview-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-detail-preview-icon.type-pdf {
    background: rgba(201, 97, 90, 0.12);
    color: #c9615a;
}

.file-detail-preview-icon.type-image {
    background: rgba(74, 123, 189, 0.12);
    color: #4a7bbd;
}

.file-detail-preview-icon.type-doc {
    background: rgba(90, 154, 110, 0.12);
    color: #5a9a6e;
}

.file-detail-preview-icon svg {
    width: 36px;
    height: 36px;
}

.file-detail-preview-name {
    font-family: 'Sora', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.4;
}

.file-detail-preview-size {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* Metadata section */
.file-detail-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-detail-section-title {
    font-family: 'Sora', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.file-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.file-detail-row-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.file-detail-row-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
}

/* Signature status section */
.file-signature-section {
    background: var(--amber-light);
    border: 1px solid rgba(201, 151, 62, 0.25);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-signature-section.signed {
    background: var(--green-light);
    border-color: rgba(90, 154, 110, 0.25);
}

.file-signature-section.viewed {
    background: var(--blue-light);
    border-color: rgba(74, 123, 189, 0.25);
}

.file-signature-title {
    font-family: 'Sora', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-signature-title svg {
    width: 14px;
    height: 14px;
}

.file-signature-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.file-detail-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.file-detail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    width: 100%;
}

.file-detail-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.file-detail-btn.primary {
    background: var(--copper);
    color: white;
}

.file-detail-btn.primary:hover {
    background: var(--copper-dark);
}

.file-detail-btn.secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.file-detail-btn.secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

/* ===== Templates Tab ===== */
.templates-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.templates-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.templates-toolbar-spacer {
    flex: 1;
}

/* ===== Template List ===== */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== Template Card ===== */
.template-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 16px;
}

.template-card:hover {
    border-color: var(--copper-light);
    box-shadow: var(--shadow-md);
}

.template-card.active {
    border-color: var(--copper);
    box-shadow: 0 0 0 2px rgba(193, 127, 89, 0.15);
}

.template-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: rgba(193, 127, 89, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--copper);
    flex-shrink: 0;
}

.template-card-icon svg {
    width: 22px;
    height: 22px;
}

.template-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.template-card-name {
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.template-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.template-job-type {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.6;
}

.template-job-type.installation { background: var(--blue-light); color: var(--blue); }
.template-job-type.maintenance  { background: var(--green-light); color: var(--green); }
.template-job-type.repair       { background: var(--red-light); color: var(--red); }
.template-job-type.inspection   { background: var(--amber-light); color: var(--amber); }
.template-job-type.general      { background: var(--bg-tertiary); color: var(--text-secondary); }

.template-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--border-color);
}

.template-field-count {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.template-card-preview {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.template-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    flex-shrink: 0;
}

.template-modified {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.template-action-btns {
    display: flex;
    gap: 6px;
}

.template-action-btn {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-action-btn svg {
    width: 13px;
    height: 13px;
}

.template-action-btn:hover {
    border-color: var(--text-tertiary);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.template-action-btn.copper {
    border-color: var(--copper);
    color: var(--copper);
}

.template-action-btn.copper:hover {
    background: rgba(193, 127, 89, 0.08);
}

/* ===== Template Preview Panel ===== */
.template-preview-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
}

.template-preview-title {
    flex: 1;
    font-family: 'Sora', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.template-preview-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

.template-preview-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.template-preview-close svg {
    width: 14px;
    height: 14px;
}

/* ===== Template Preview Content ===== */
.template-preview {
    padding: 20px 24px;
    flex: 1;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-white);
}

/* Merge field highlighted span */
.merge-field {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    background: rgba(193, 127, 89, 0.12);
    color: var(--copper-dark);
    border: 1px solid rgba(193, 127, 89, 0.3);
    border-radius: 4px;
    font-family: 'DM Mono', 'Fira Mono', monospace;
    font-size: 0.82em;
    font-weight: 600;
    white-space: nowrap;
    cursor: default;
    transition: background var(--transition-fast);
}

.merge-field:hover {
    background: rgba(193, 127, 89, 0.2);
}

.merge-field::before {
    content: '{{';
    opacity: 0.5;
    font-weight: 400;
    margin-right: 2px;
}

.merge-field::after {
    content: '}}';
    opacity: 0.5;
    font-weight: 400;
    margin-left: 2px;
}

/* ===== Template Editor ===== */
.template-editor-area {
    padding: 16px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.template-editor-label {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    flex: 1;
    font-style: italic;
}

.template-editor {
    width: 100%;
    min-height: 320px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'DM Mono', 'Fira Mono', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-secondary);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

.template-editor:focus {
    border-color: var(--copper);
    background: var(--bg-white);
}

.template-editor-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    background: var(--bg-secondary);
}

/* ===== Merge Fields Info Bar ===== */
.merge-fields-info {
    padding: 12px 16px;
    background: rgba(193, 127, 89, 0.05);
    border: 1px solid rgba(193, 127, 89, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.merge-fields-info-icon {
    width: 18px;
    height: 18px;
    color: var(--copper);
    flex-shrink: 0;
    margin-top: 1px;
}

.merge-fields-info-icon svg {
    width: 18px;
    height: 18px;
}

.merge-fields-info-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.merge-fields-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.merge-field-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: rgba(193, 127, 89, 0.1);
    color: var(--copper-dark);
    border: 1px solid rgba(193, 127, 89, 0.25);
    border-radius: 4px;
    font-size: 0.72rem;
    font-family: 'DM Mono', monospace;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.merge-field-tag:hover {
    background: rgba(193, 127, 89, 0.2);
}

/* ===== Templates Layout (two-column when preview open) ===== */
.templates-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    transition: grid-template-columns var(--transition-base);
}

.templates-layout.preview-open {
    grid-template-columns: 1fr 420px;
    align-items: start;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .documents-layout {
        grid-template-columns: 1fr;
    }

    .folder-tree {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }

    .folder-tree-header {
        display: none;
    }

    .folder-item {
        padding: 7px 10px;
    }

    .templates-layout.preview-open {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .documents-container {
        padding: 0 16px 24px;
    }

    .file-list {
        grid-template-columns: 1fr 1fr;
    }

    .file-detail-panel {
        width: 100%;
    }

    .template-card {
        grid-template-columns: auto 1fr;
    }

    .template-card-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
    }
}
