/* ==========================================================================
   OmniRSS Main App Layout & Splitter System
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--custom-font-family, var(--font-sans));
  font-size: var(--font-size-base);
  background-color: var(--bg-app);
  color: var(--text-primary);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* App Container (Flex Column) */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
   Top Navigation & Actions Bar
   -------------------------------------------------------------------------- */
.top-header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left, .header-right, .header-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: var(--font-size-md);
  color: var(--text-primary);
  margin-right: 12px;
  cursor: pointer;
}

.brand-logo svg {
  color: var(--accent-orange);
}

.brand-badge {
  font-size: 10px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  padding: 1px 5px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
  height: 28px;
  padding: 0 8px;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-color-subtle);
}

.icon-btn.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.icon-btn.busy svg,
.animate-spin {
  animation: spin 0.8s linear infinite;
}

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

.icon-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff !important;
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
}

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

/* Global Search Input */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  height: 26px;
  width: 180px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 0 24px 0 8px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  transition: width 0.2s ease, border-color 0.15s;
}

.search-box input:focus {
  width: 240px;
  border-color: var(--border-color-focus);
  outline: none;
}

.search-box .search-icon {
  position: absolute;
  right: 6px;
  color: var(--text-muted);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Workspace (3-Pane Grid / Flex)
   -------------------------------------------------------------------------- */
.workspace-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height) - var(--status-bar-height));
  position: relative;
  overflow: hidden;
}

/* Left Pane: Subscriptions Tree */
.pane-tree {
  width: 250px;
  min-width: 180px;
  max-width: 480px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Right Pane: Split Articles & Reader */
.pane-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Center Top Pane: Article List */
.pane-list {
  height: 45%;
  min-height: 120px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Center Bottom Pane: Article Reader */
.pane-reader {
  flex: 1;
  min-height: 150px;
  background: var(--bg-reader);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Interactive Splitters (Resizers)
   -------------------------------------------------------------------------- */
.splitter-v {
  width: var(--splitter-width);
  background: var(--splitter-color);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background-color 0.15s;
  z-index: 5;
}

.splitter-v:hover, .splitter-v.dragging {
  background: var(--splitter-hover);
}

.splitter-h {
  height: var(--splitter-width);
  background: var(--splitter-color);
  cursor: row-resize;
  flex-shrink: 0;
  transition: background-color 0.15s;
  z-index: 5;
}

.splitter-h:hover, .splitter-h.dragging {
  background: var(--splitter-hover);
}

/* --------------------------------------------------------------------------
   Bottom Status Bar
   -------------------------------------------------------------------------- */
.status-bar {
  height: var(--status-bar-height);
  background: var(--bg-status);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 10;
}

.status-left, .status-center, .status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
}
.status-indicator.busy {
  background: var(--accent-orange);
  animation: pulse 1.2s infinite;
}
.status-indicator.error {
  background: var(--accent-red);
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.kbd-badge {
  background: var(--bg-badge);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 30px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-modal);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
}

.toast.success svg { color: var(--accent-green); }
.toast.error svg { color: var(--accent-red); }
.toast.info svg { color: var(--accent-primary); }

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Real Progress Bar & Pill in Status Bar */
.status-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-active, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-primary);
  animation: fadeIn 0.2s ease;
  transition: all 0.3s ease;
  max-width: 480px;
}

.status-progress-pill.finished {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.progress-bar-track {
  width: 70px;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary, #3b82f6);
  border-radius: 3px;
  transition: width 0.25s ease-out;
}

.status-progress-pill.finished .progress-bar-fill {
  background: #10b981;
}

.progress-percent {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 11px;
  color: var(--accent-primary, #3b82f6);
  min-width: 28px;
  flex-shrink: 0;
}

.status-progress-pill.finished .progress-percent {
  color: #10b981;
}

.progress-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
  color: var(--text-secondary);
}

.spinner-sm {
  width: 10px;
  height: 10px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* Stop Refresh Button inside Progress Pill */
.btn-stop-refresh {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  line-height: 1.4;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-stop-refresh:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.04);
}

.btn-stop-refresh:active {
  transform: scale(0.96);
}

.status-progress-pill.finished .btn-stop-refresh {
  display: none !important;
}

