/**
 * textedit.css v1
 * Namespaced styles for TextEdit service
 * All classes prefixed with textedit- to prevent conflicts
 */

/* ==================== MODAL OVERLAY ==================== */

.textedit-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.textedit-modal.hidden {
  display: none;
}

.textedit-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.textedit-modal-content {
  position: relative;
  background: var(--popover-bg, #303030);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==================== MODAL HEADER ==================== */

.textedit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default, #4a4a4a);
}

.textedit-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.textedit-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #999);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.textedit-modal-close:hover {
  background: var(--hover-bg, #404040);
  color: var(--text-primary, #ffffff);
}

/* ==================== MODAL BODY ==================== */

.textedit-modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==================== FORM FIELDS ==================== */

.textedit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.textedit-field-grow {
  flex: 1;
  min-height: 0;
}

.textedit-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #999);
}

.textedit-input {
  padding: 10px 12px;
  background: var(--bg-view, #1e1e1e);
  border: 1px solid var(--border-default, #4a4a4a);
  border-radius: 6px;
  color: var(--text-primary, #ffffff);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textedit-input:focus {
  border-color: var(--accent-color, #3584e4);
  box-shadow: 0 0 0 2px rgba(53, 132, 228, 0.25);
}

.textedit-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.textedit-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-view, #1e1e1e);
  border: 1px solid var(--border-default, #4a4a4a);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textedit-input-group:focus-within {
  border-color: var(--accent-color, #3584e4);
  box-shadow: 0 0 0 2px rgba(53, 132, 228, 0.25);
}

.textedit-input-group .textedit-input-name {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 6px 0 0 6px;
}

.textedit-input-group .textedit-input-name:focus {
  border-color: transparent;
  box-shadow: none;
}

.textedit-input-ext {
  padding: 10px 12px 10px 0;
  color: var(--text-secondary, #999);
  font-size: 14px;
  font-family: inherit;
  user-select: none;
  white-space: nowrap;
}

.textedit-location {
  padding: 10px 12px;
  background: var(--bg-view, #1e1e1e);
  border-radius: 6px;
  color: var(--text-secondary, #999);
  font-size: 13px;
  font-family: 'Ubuntu Mono', monospace;
}

.textedit-textarea {
  flex: 1;
  min-height: 200px;
  padding: 12px;
  background: var(--bg-view, #1e1e1e);
  border: 1px solid var(--border-default, #4a4a4a);
  border-radius: 6px;
  color: var(--text-primary, #ffffff);
  font-family: 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textedit-textarea:focus {
  border-color: var(--accent-color, #3584e4);
  box-shadow: 0 0 0 2px rgba(53, 132, 228, 0.25);
}

.textedit-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==================== MODAL FOOTER ==================== */

.textedit-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-default, #4a4a4a);
  gap: 16px;
}

.textedit-status {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary, #999);
}

.textedit-status-error {
  color: var(--error-color, #e74c3c);
}

.textedit-status-success {
  color: var(--success-color, #27ae60);
}

.textedit-status-info {
  color: var(--accent-color, #3584e4);
}

.textedit-buttons {
  display: flex;
  gap: 8px;
}

/* ==================== BUTTONS ==================== */

.textedit-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.textedit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.textedit-btn-primary {
  background: var(--accent-color, #3584e4);
  color: #ffffff;
}

.textedit-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover, #2b6fc3);
}

.textedit-btn-secondary {
  background: var(--hover-bg, #404040);
  color: var(--text-primary, #ffffff);
}

.textedit-btn-secondary:hover:not(:disabled) {
  background: var(--active-bg, #505050);
}

/* ==================== STANDALONE APP ==================== */

.textedit-standalone {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-base, #242424);
}

.textedit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--headerbar-bg, #303030);
  border-bottom: 1px solid var(--border-default, #4a4a4a);
  gap: 16px;
}

.textedit-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.textedit-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.textedit-filename-input {
  padding: 6px 12px;
  background: var(--bg-view, #1e1e1e);
  border: 1px solid var(--border-default, #4a4a4a);
  border-radius: 6px;
  color: var(--text-primary, #ffffff);
  font-size: 14px;
  width: 200px;
  outline: none;
}

.textedit-filename-input:focus {
  border-color: var(--accent-color, #3584e4);
}

.textedit-toolbar-btn {
  padding: 6px 16px;
  background: var(--accent-color, #3584e4);
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.textedit-toolbar-btn:hover:not(:disabled) {
  background: var(--accent-hover, #2b6fc3);
}

.textedit-toolbar-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.textedit-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ==================== SIDEBAR / FOLDER PICKER ==================== */

.textedit-sidebar {
  width: 220px;
  background: var(--sidebar-bg, #2d2d2d);
  border-right: 1px solid var(--border-default, #4a4a4a);
  overflow-y: auto;
}

.textedit-folder-picker {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.textedit-folder-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #999);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-default, #4a4a4a);
}

.textedit-folder-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.textedit-folder-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 6px;
  cursor: pointer;
  color: var(--text-primary, #ffffff);
  font-size: 13px;
  transition: background 0.1s;
}

.textedit-folder-item:hover {
  background: var(--hover-bg, #404040);
}

.textedit-folder-item.selected {
  background: var(--accent-color, #3584e4);
  color: #ffffff;
}

.textedit-folder-toggle {
  width: 16px;
  font-size: 10px;
  text-align: center;
  opacity: 0.7;
}

.textedit-folder-icon {
  font-size: 14px;
}

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

.textedit-folder-loading,
.textedit-folder-empty,
.textedit-folder-error {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary, #999);
  font-size: 13px;
}

.textedit-folder-error {
  color: var(--error-color, #e74c3c);
}

.textedit-folder-selected {
  padding: 12px 16px;
  border-top: 1px solid var(--border-default, #4a4a4a);
  font-size: 12px;
}

.textedit-folder-label {
  color: var(--text-secondary, #999);
  margin-right: 4px;
}

.textedit-folder-path {
  color: var(--text-primary, #ffffff);
  font-family: 'Ubuntu Mono', monospace;
}

/* ==================== EDITOR AREA ==================== */

.textedit-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.textedit-textarea.full {
  flex: 1;
  min-height: unset;
  border: none;
  border-radius: 0;
  resize: none;
}

.textedit-textarea.full:focus {
  box-shadow: none;
}

/* ==================== STATUS BAR ==================== */

.textedit-status-bar {
  padding: 6px 16px;
  background: var(--headerbar-bg, #303030);
  border-top: 1px solid var(--border-default, #4a4a4a);
  font-size: 12px;
  color: var(--text-secondary, #999);
}
