/**
 * components.css - Buttons, dropdowns, modals
 */

/* Buttons */
.btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

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

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Small buttons */
.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* Selection Tooltip */
.selection-tooltip {
    position: absolute;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--text-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.15s;
}

.selection-tooltip.visible {
    display: flex;
    opacity: 1;
}

.selection-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: var(--text-primary) transparent transparent;
}

.selection-tooltip button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--bg-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.selection-tooltip button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.selection-tooltip button svg {
    width: 16px;
    height: 16px;
}

/* Copy button */
.btn-copy {
    position: relative;
}

.btn-copy.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-copy.copied .copy-icon {
    display: none;
}

.btn-copy.copied .check-icon {
    display: block !important;
}

/* Clear button */
.btn-clear:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dropdown-trigger:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.dropdown-trigger svg {
    width: 14px;
    height: 14px;
}

.dropdown-trigger .dropdown-arrow {
    width: 12px;
    height: 12px;
    margin-left: 2px;
    transition: transform 0.2s;
}

.dropdown.open .dropdown-trigger .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown.open .dropdown-content {
    display: block;
}

/* Left-aligned dropdown for file actions */
.file-actions .dropdown-content {
    right: auto;
    left: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

/* Inline confirm button */
.dropdown-item.confirm-btn {
    display: none;
    background: var(--danger-light);
    color: var(--danger);
    font-weight: 500;
}

.dropdown-item.confirm-btn:hover {
    background: var(--danger);
    color: white;
}

.dropdown-item.confirm-btn.visible {
    display: flex;
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Dropdown sections */
.dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 4px 14px 8px;
}

/* YAML Dropdown */
.yaml-dropdown {
    min-width: 200px;
}

.yaml-field-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.yaml-field-option:hover {
    background: var(--bg-secondary);
}

.yaml-field-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.yaml-field-option input[type="checkbox"]:disabled {
    opacity: 0.5;
}

.yaml-insert-btn {
    margin: 8px 10px;
    width: calc(100% - 20px);
    justify-content: center;
    background: var(--accent-color);
    color: white;
    border-radius: 4px;
    font-weight: 500;
}

.yaml-insert-btn:hover {
    background: var(--accent-hover);
}

/* Mode Slider */
.mode-slider {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.mode-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mode-btn svg {
    width: 14px;
    height: 14px;
}

/* Sync Scroll Toggle */
.sync-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
}

.sync-toggle:hover {
    background: var(--bg-secondary);
}

.sync-toggle input {
    display: none;
}

.sync-indicator {
    width: 32px;
    height: 18px;
    background: var(--bg-tertiary);
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
}

.sync-indicator::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.sync-toggle input:checked + .sync-indicator {
    background: var(--accent-color);
}

.sync-toggle input:checked + .sync-indicator::after {
    transform: translateX(14px);
}

/* Toolbar Dropdowns */
.toolbar-dropdown {
    position: relative;
    display: inline-block;
}

.toolbar-dropdown-trigger {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-dropdown-trigger:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.toolbar-dropdown-trigger .arrow {
    width: 10px;
    height: 10px;
    transition: transform 0.2s;
}

.toolbar-dropdown.open .toolbar-dropdown-trigger .arrow {
    transform: rotate(180deg);
}

.toolbar-dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 1000;
    overflow: hidden;
}

.toolbar-dropdown.open .toolbar-dropdown-content {
    display: block;
}

.toolbar-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.toolbar-dropdown-item:hover {
    background: var(--bg-secondary);
}

.toolbar-dropdown-section {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.toolbar-dropdown-section:last-child {
    border-bottom: none;
}

.toolbar-dropdown-section-title {
    padding: 4px 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Status indicator colors */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-indicator.no-status { background: #d1d5db; }
.status-indicator.draft { background: var(--status-draft); }
.status-indicator.in-progress { background: var(--status-in-progress); }
.status-indicator.reviewed { background: var(--status-reviewed); }
.status-indicator.released { background: var(--status-released); }

/* Overlay base */
.pdf-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.pdf-overlay.visible {
    display: flex;
}

/* Dialog base */
.pdf-dialog {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.pdf-dialog h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #212529;
}

.pdf-section {
    margin-bottom: 20px;
}

.pdf-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Filename input in save dialogs */
.save-filename-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
    color: #212529;
}

.save-filename-input:focus {
    outline: none;
    border-color: #4a90d9;
    background: white;
}

.pdf-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f1f3f4;
}

.pdf-option:last-child {
    border-bottom: none;
}

.pdf-option label {
    font-size: 13px;
    color: #212529;
}

.pdf-option select,
.pdf-option input[type="number"] {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    color: #212529;
    min-width: 140px;
}

.pdf-option input[type="number"] {
    width: 80px;
    min-width: auto;
}

.pdf-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: flex-end;
}

.pdf-actions .btn {
    padding: 10px 20px;
}

/* PDF Generation Status */
.pdf-status {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: #212529;
    font-size: 14px;
}

.pdf-status.visible {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Template dropdown - hidden on desktop by default */
.template-dropdown-section {
    display: none;
}

/* Template Cards */
.template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.template-card {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.template-card:hover {
    border-color: #adb5bd;
}

.template-card.selected {
    border-color: #4a90d9;
    background: #f0f7ff;
}

.template-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.template-card-desc {
    font-size: 11px;
    color: #6c757d;
}

/* Custom Template Builder */
.custom-builder {
    display: none;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.custom-builder.visible {
    display: block;
}

/* Toggle for custom */
.customize-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4a90d9;
    cursor: pointer;
    padding: 8px 0;
    margin-top: 8px;
}

.customize-toggle:hover {
    text-decoration: underline;
}

.customize-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}

.customize-toggle.expanded svg {
    transform: rotate(180deg);
}

/* Template Actions */
.template-actions {
    display: flex;
    gap: 6px;
}

.template-actions .btn {
    padding: 4px 10px;
    font-size: 11px;
}

/* Saved Templates Modal */
.templates-modal {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.98);
    z-index: 10;
    flex-direction: column;
    padding: 20px;
    border-radius: 12px;
}

.templates-modal.visible {
    display: flex;
}

.templates-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.templates-modal-header h4 {
    margin: 0;
    font-size: 16px;
    color: #212529;
}

.templates-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.saved-template-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background 0.15s;
}

.saved-template-item:last-child {
    border-bottom: none;
}

.saved-template-item:hover {
    background: #f8f9fa;
}

.saved-template-info {
    flex: 1;
}

.saved-template-name {
    font-size: 13px;
    font-weight: 500;
    color: #212529;
}

.saved-template-preview {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

.saved-template-actions {
    display: flex;
    gap: 6px;
}

.saved-template-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.saved-template-actions button:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.saved-template-actions .delete-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.no-templates {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-size: 13px;
}

/* Save template dialog */
.save-name-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 16px;
}

.save-name-input:focus {
    outline: none;
    border-color: #4a90d9;
}

/* Library Dialog */
.library-dialog {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.library-dialog h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
}

.library-dialog h3 svg {
    width: 18px;
    height: 18px;
    color: var(--accent-color);
}

.library-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 12px;
    min-height: 150px;
    max-height: 350px;
}

/* Grid header */
.library-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px 60px 28px;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 10px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.library-item {
    display: grid;
    grid-template-columns: 1fr 80px 80px 60px 28px;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}

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

.library-item:hover {
    background: #f8f9fa;
}

.library-item-title {
    font-weight: 500;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item-time,
.library-item-words {
    font-size: 12px;
    color: #6c757d;
    text-align: right;
}

.library-item-status {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: center;
}

.status-draft { color: #6c757d; }
.status-in-progress { color: #f59e0b; }
.status-reviewed { color: #3b82f6; }
.status-released { color: #22c55e; }

/* Library Save Form */
.library-save-form {
    display: none;
    border-top: 1px solid #e9ecef;
    padding-top: 16px;
    margin-top: 4px;
}

.library-save-form.visible {
    display: block;
}

.library-form-row {
    margin-bottom: 12px;
}

.library-form-row:last-child {
    margin-bottom: 0;
}

.library-form-row label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.library-form-row input,
.library-form-row select,
.library-form-row textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: #fff;
    color: #212529;
}

.library-form-row input:focus,
.library-form-row select:focus,
.library-form-row textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.library-form-row textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.library-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.library-item-actions {
    display: flex;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.library-item:hover .library-item-actions {
    opacity: 1;
}

.library-item-actions button {
    padding: 4px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-item-actions button svg {
    width: 14px;
    height: 14px;
    color: #adb5bd;
}

.library-item-actions button:hover {
    background: #fee2e2;
}

.library-item-actions button:hover svg {
    color: #dc2626;
}

.library-empty {
    padding: 50px 20px;
    text-align: center;
    color: #6c757d;
}

.library-empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.library-empty p {
    font-size: 13px;
    margin: 0;
}

.library-empty span {
    font-size: 11px;
    display: block;
    margin-top: 4px;
}

.library-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
