/* ============================================================
   CLIP DECK — Stylesheet
   
   Organised:  Reset → Variables → Layout → Components → States
   
   CSS CONCEPTS USED:
   - CSS custom properties (variables) for consistent colours
   - Flexbox and CSS Grid for layout
   - Transitions and keyframe animations for interactivity
   - :hover and :active pseudo-classes for feedback
   - rem units for accessibility-friendly sizing
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;   /* border-box: padding is INSIDE the width, not added on top */
  margin: 0;
  padding: 0;
}

/* --- Custom Properties (Variables) ---
   Defined once, used everywhere. Change a colour here = changes everywhere.
   Accessed with var(--name) in any CSS property. */
:root {
  --green-dark: #2D6A4F;
  --green-mid: #52796F;
  --green-light: #40916C;
  --green-bg: #f0f7f3;
  --bg: #F0EFEB;
  --card-bg: #fff;
  --border: #e2e1dc;
  --border-focus: #2D6A4F;
  --text-primary: #2D3A35;
  --text-secondary: #52524e;
  --text-muted: #8a8a86;
  --text-faint: #a0a09c;
  --red-muted: #95685a;
  --red-btn: #c0392b;
  --badge-bg: #e8e7e3;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 4px 16px rgba(45,106,79,0.18);
  --shadow-menu: 0 8px 30px rgba(0,0,0,0.15);
}

body {
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text-primary);
  line-height: 1.55;
}

/* --- Utility --- */
.hidden { display: none !important; }


/* ============================================================
   HEADER
   ============================================================ */
.header {
  background: var(--green-dark);
  padding: 0 20px;
  position: sticky;          /* stays at top when you scroll */
  top: 0;
  z-index: 50;               /* sits above other content */
  box-shadow: 0 2px 20px rgba(45,106,79,0.25);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;            /* don't shrink on small screens */
}

.title {
  font-size: 1.25rem;        /* rem = relative to root font size (16px default) */
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  margin-top: 1px;
  font-family: var(--font-mono);
}


/* ============================================================
   HEADER BUTTONS
   ============================================================ */
.add-cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 7px 14px;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.add-cat-btn:hover { background: rgba(255,255,255,0.22); }

/* Gear button */
.gear-wrapper { position: relative; }

.gear-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.gear-btn:hover { background: rgba(255,255,255,0.22); }

/* Gear dropdown */
.gear-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
  border: 1.5px solid var(--border);
  min-width: 180px;
  overflow: hidden;
  animation: popIn 0.15s ease;
  z-index: 60;
}

.gear-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  border: none;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.1s;
}
.gear-item:hover { background: var(--green-bg); }
.gear-item--danger { color: var(--red-muted); }


/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}


/* ============================================================
   EMPTY STATE (shown when no data is loaded)
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon { margin-bottom: 16px; opacity: 0.6; }

.empty-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 0.875rem;
  color: #6b6b67;
  max-width: 360px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.empty-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--green-light); }

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--card-bg);
  color: var(--green-dark);
  border: 1.5px solid var(--green-dark);
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--green-bg); }


/* ============================================================
   SECTIONS (pinned groups)
   ============================================================ */
.section {
  margin-bottom: 28px;
  animation: fadeSlide 0.3s ease;
}

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

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark);
  letter-spacing: -0.01em;
}

.section-actions {
  display: flex;
  gap: 2px;
}


/* ============================================================
   SNIPPET CARDS
   ============================================================ */

/* Grid layout — auto-fills columns of at least 240px */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: popIn 0.25s ease;
}
.card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.card:active {
  transform: translateY(0) scale(0.98);
}

/* "Copied!" flash state */
.card--copied {
  border-color: var(--green-dark);
  background: var(--green-bg);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

.card-actions {
  display: flex;
  gap: 2px;
}

.card-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;     /* truncate after 3 lines with "..." */
  -webkit-box-orient: vertical;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 4px;
}

.copied-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #fff;
  background: var(--green-dark);
  border-radius: 5px;
  padding: 3px 8px;
  font-family: var(--font-mono);
}

.click-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}


/* ============================================================
   COLLAPSIBLE SECTIONS (unpinned groups)
   ============================================================ */
.collapsed-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
}
.collapsible-header:hover { background: rgba(45,106,79,0.04); }

.collapsible-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Chevron rotation when open */
.chevron {
  transition: transform 0.25s;
}
.chevron--open {
  transform: rotate(90deg);
}

.badge {
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: #6b6b67;
  border-radius: 10px;
  padding: 1px 8px;
  font-family: var(--font-mono);
}

.collapsible-actions {
  display: flex;
  gap: 2px;
}

.collapsed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding: 10px 6px 16px;
}


/* ============================================================
   SHARED ICON BUTTON
   ============================================================ */
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(45,106,79,0.08); }

/* Smaller variant used inside collapsible headers */
.icon-btn--sm {
  width: 26px;
  height: 26px;
  border-radius: 5px;
}


/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;                  /* shorthand: top/right/bottom/left all 0 */
  background: rgba(30,40,35,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: popIn 0.2s ease;
}
.modal--small { max-width: 380px; }

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

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 30px;
  height: 30px;
}


/* ============================================================
   FORMS (inside modals)
   ============================================================ */
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--card-bg);
}
.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}

.form-textarea {
  resize: vertical;
  line-height: 1.55;
}

.form-textarea--mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.btn-save {
  padding: 9px 20px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.btn-save:hover { background: var(--green-light); }
.btn-save:disabled { opacity: 0.5; cursor: default; }

.btn-cancel {
  padding: 9px 16px;
  background: transparent;
  color: #6b6b67;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-delete {
  padding: 9px 20px;
  background: var(--red-btn);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}

/* Inline rename (used inside section headers) */
.inline-rename {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-input {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  width: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inline-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}

.btn-inline-save {
  padding: 4px 12px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-inline-cancel {
  padding: 4px 8px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 5px;
  font-size: 0.875rem;
  cursor: pointer;
}

/* Import modal tabs */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1.5px solid var(--border);
}

.tab-btn {
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn--active {
  color: var(--green-dark);
  border-bottom-color: var(--green-dark);
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone--active {
  border-color: var(--green-dark);
  background: var(--green-bg);
}
.drop-zone-text { font-size: 0.875rem; color: var(--text-secondary); margin-top: 8px; }
.drop-zone-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* Simple message for empty groups */
.empty-msg {
  font-size: 0.8125rem;
  color: var(--text-faint);
  font-style: italic;
  padding: 12px 0;
}

/* Confirmation dialog text */
.confirm-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}


/* ============================================================
   ANIMATIONS
   ============================================================ */

/* Card appears: scales up from slightly smaller */
@keyframes popIn {
  0%   { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Sections slide down into view */
@keyframes fadeSlide {
  0%   { transform: translateY(-6px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
