/* ========================================
   Text Vault - Chrome Extension Styles
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== Theme Variables ========== */
:root,
[data-theme="dark"] {
  --bg-primary: #1a1814;
  --bg-secondary: #242019;
  --bg-card: #1f1c17;
  --bg-elevated: #2a2620;
  
  --text-primary: #f5f0e8;
  --text-secondary: #a09080;
  --text-muted: #6b6050;
  
  --highlight: #f0b429;
  --highlight-glow: #ffc94d;
  --highlight-dim: rgba(240, 180, 41, 0.15);
  
  --border: #3a3530;
  --border-hover: #4a4540;
  
  --category-quotes: #f0b429;
  --category-ideas: #4da6ff;
  --category-research: #45c48a;
  --category-inspiration: #e066a0;
  
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-sm: 6px;
  
  --font-display: 'Georgia', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8f6f3;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f0ede8;
  
  --text-primary: #2d2a26;
  --text-secondary: #5c5850;
  --text-muted: #8a8578;
  
  --highlight: #d9a020;
  --highlight-glow: #f0b429;
  --highlight-dim: rgba(217, 160, 32, 0.12);
  
  --border: #e0dcd5;
  --border-hover: #ccc8c0;
  
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="sepia"] {
  --bg-primary: #f4e8d8;
  --bg-secondary: #faf3e8;
  --bg-card: #fdf8f0;
  --bg-elevated: #efe4d4;
  
  --text-primary: #3d3530;
  --text-secondary: #6b5f55;
  --text-muted: #998b7d;
  
  --highlight: #b87333;
  --highlight-glow: #d4894a;
  --highlight-dim: rgba(184, 115, 51, 0.15);
  
  --border: #d8cfc2;
  --border-hover: #c5b9a8;
  
  --shadow: 0 4px 20px rgba(60, 40, 20, 0.1);
}

[data-theme="ocean"] {
  --bg-primary: #1a2735;
  --bg-secondary: #1f2f40;
  --bg-card: #233548;
  --bg-elevated: #2a3f55;
  
  --text-primary: #e8f0f5;
  --text-secondary: #a0b8c8;
  --text-muted: #6b8595;
  
  --highlight: #4da6ff;
  --highlight-glow: #7fc4ff;
  --highlight-dim: rgba(77, 166, 255, 0.15);
  
  --border: #35485a;
  --border-hover: #455a70;
  
  --shadow: 0 4px 20px rgba(0, 20, 40, 0.4);
}

body {
  width: 380px;
  max-height: 520px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

.container {
  display: flex;
  flex-direction: column;
  height: 520px;
}

/* ========== Header ========== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--highlight-dim);
  border-radius: var(--radius);
  color: var(--highlight);
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo-text h1 .accent {
  background: linear-gradient(135deg, var(--highlight), var(--highlight-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 11px;
  color: var(--text-muted);
}

.counter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--highlight);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

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

/* ========== Search Section ========== */
.search-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.search-box {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px var(--highlight-dim);
}

.filter-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}

.filter-btn.active {
  background: var(--highlight);
  border-color: var(--highlight);
  color: var(--bg-primary);
  font-weight: 500;
}

/* ========== Highlights Container ========== */
.highlights-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.highlights-container::-webkit-scrollbar {
  width: 5px;
}

.highlights-container::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.highlights-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ========== Empty State ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--highlight-dim);
  border-radius: 50%;
  color: var(--highlight);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ========== Highlight Card ========== */
.highlight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
  animation: fadeIn 0.3s ease-out;
}

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

.highlight-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.category-tag {
  padding: 3px 10px;
  background: var(--bg-elevated);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.category-tag.quotes { color: var(--category-quotes); }
.category-tag.ideas { color: var(--category-ideas); }
.category-tag.research { color: var(--category-research); }
.category-tag.inspiration { color: var(--category-inspiration); }

.card-date {
  font-size: 11px;
  color: var(--text-muted);
}

.card-text {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--highlight-dim);
  white-space: pre-wrap;
}

.card-text .bold {
  font-weight: bold;
}

.card-text .italic {
  font-style: italic;
}

.card-text .indent {
  padding-left: 20px;
  display: block;
}

.card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-source a {
  color: var(--text-secondary);
  text-decoration: none;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-source a:hover {
  color: var(--highlight);
}

.card-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.highlight-card:hover .card-actions {
  opacity: 1;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--border);
  color: var(--highlight);
}

.action-btn.edit:hover {
  color: var(--highlight);
}

.action-btn.delete:hover {
  color: #e05050;
}

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

/* ========== Footer ========== */
.footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--highlight);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--highlight-glow);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

/* ========== Modal ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 320px;
  animation: fadeIn 0.2s ease-out;
}

.modal-content h3 {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.export-option:hover {
  background: var(--bg-elevated);
  border-color: var(--highlight);
  color: var(--highlight);
}

.export-option svg {
  color: var(--text-muted);
}

.export-option:hover svg {
  color: var(--highlight);
}

.btn-close {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-close:hover {
  background: var(--bg-elevated);
}

/* ========== Edit Modal ========== */
.edit-modal-content {
  max-width: 360px;
}

.formatting-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.format-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.format-btn:hover {
  background: var(--border);
  color: var(--highlight);
  border-color: var(--highlight);
}

.format-btn.active {
  background: var(--highlight);
  color: var(--bg-primary);
  border-color: var(--highlight);
}

.color-btn {
  width: 28px;
  height: 28px;
  padding: 0;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.rich-editor {
  width: 100%;
  min-height: 120px;
  max-height: 200px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  white-space: pre-wrap;
}

.rich-editor:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px var(--highlight-dim);
}

.rich-editor:empty::before {
  content: "Edit your highlight...";
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

/* ========== Theme Switcher ========== */
.theme-switcher {
  position: fixed;
  bottom: 70px;
  right: 16px;
  z-index: 50;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  background: var(--border);
  color: var(--highlight);
}

.theme-options {
  position: absolute;
  bottom: 44px;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease-out;
}

.theme-options.hidden {
  display: none;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.theme-option:hover {
  background: var(--bg-elevated);
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.theme-swatch.dark {
  background: linear-gradient(135deg, #1a1814 50%, #f0b429 50%);
}

.theme-swatch.light {
  background: linear-gradient(135deg, #f8f6f3 50%, #d9a020 50%);
}

.theme-swatch.sepia {
  background: linear-gradient(135deg, #f4e8d8 50%, #b87333 50%);
}

.theme-swatch.ocean {
  background: linear-gradient(135deg, #1a2735 50%, #4da6ff 50%);
}

/* ========== Toast Notification ========== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
