/* ============================================================================
   ANNOTATION STYLES — Samacheer Kalvi Live Project
   Mobile-first, namespaced with sk-annotation-*
   ============================================================================ */

:root {
  --sk-ann-primary: #2563eb;
  --sk-ann-primary-light: #dbeafe;
  --sk-ann-primary-dark: #1d4ed8;
  --sk-ann-success: #16a34a;
  --sk-ann-success-light: #dcfce7;
  --sk-ann-danger: #dc2626;
  --sk-ann-danger-light: #fef2f2;
  --sk-ann-text: #1e293b;
  --sk-ann-text-secondary: #64748b;
  --sk-ann-bg: #ffffff;
  --sk-ann-bg-soft: #f8fafc;
  --sk-ann-border: #e2e8f0;
  --sk-ann-shadow: 0 4px 24px rgba(0,0,0,0.12);
  --sk-ann-shadow-lg: 0 12px 40px rgba(0,0,0,0.16);
  --sk-ann-radius: 12px;
  --sk-ann-radius-sm: 8px;
  --sk-ann-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --sk-ann-highlight: #fef08a;
  --sk-ann-highlight-hover: #fde047;
  --sk-ann-highlight-border: #eab308;
  --sk-ann-transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Highlights ── */
.annotation-highlight {
  background: var(--sk-ann-highlight);
  border-bottom: 2px solid var(--sk-ann-highlight-border);
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 3px;
  transition: all var(--sk-ann-transition);
  -webkit-tap-highlight-color: transparent;
}
.annotation-highlight:hover,
.annotation-highlight:active {
  background: var(--sk-ann-highlight-hover);
  box-shadow: 0 1px 4px rgba(234,179,8,0.3);
}
.annotation-highlight.new { animation: sk-hl-pulse 0.8s ease; }
@keyframes sk-hl-pulse {
  0% { background: #86efac; box-shadow: 0 0 0 4px rgba(34,197,94,0.2); }
  50% { background: #bbf7d0; }
  100% { background: var(--sk-ann-highlight); box-shadow: none; }
}

/* ══════════════════════════════════════
   MODAL (Create / Edit) — Bottom Sheet on Mobile
   ══════════════════════════════════════ */
.sk-annotation-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  font-family: var(--sk-ann-font);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  display: flex;
  align-items: flex-end;       /* Bottom sheet by default (mobile-first) */
  justify-content: center;
}
.sk-annotation-modal--visible {
  opacity: 1;
  pointer-events: all;
}

.sk-annotation-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sk-annotation-panel {
  position: relative;
  background: var(--sk-ann-bg);
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--sk-ann-shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
}
.sk-annotation-modal--visible .sk-annotation-panel {
  transform: translateY(0);
}

/* Drag indicator (mobile) */
.sk-annotation-panel::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--sk-ann-border);
  border-radius: 2px;
  margin: 10px auto 4px;
}

/* Scrollbar */
.sk-annotation-panel::-webkit-scrollbar { width: 5px; }
.sk-annotation-panel::-webkit-scrollbar-thumb { background: var(--sk-ann-border); border-radius: 3px; }

/* ── Panel Header ── */
.sk-annotation-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sk-ann-border);
  position: sticky;
  top: 0;
  background: var(--sk-ann-bg);
  z-index: 1;
}
.sk-annotation-panel-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--sk-ann-primary-light);
  color: var(--sk-ann-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sk-annotation-panel-icon--edit {
  background: var(--sk-ann-success-light);
  color: var(--sk-ann-success);
}
.sk-annotation-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--sk-ann-text);
  flex: 1;
}
.sk-annotation-close-btn {
  background: none; border: none;
  color: var(--sk-ann-text-secondary);
  cursor: pointer; padding: 8px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--sk-ann-transition);
  min-width: 40px; min-height: 40px;    /* Touch-friendly */
}
.sk-annotation-close-btn:hover { background: var(--sk-ann-bg-soft); color: var(--sk-ann-text); }

/* ── Selected Text ── */
.sk-annotation-selected-text {
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: var(--sk-ann-bg-soft);
  border-radius: var(--sk-ann-radius-sm);
  border-left: 3px solid var(--sk-ann-primary);
  font-size: 13px; line-height: 1.5;
  color: var(--sk-ann-text-secondary);
  font-style: italic;
}
.sk-annotation-quote-mark {
  color: var(--sk-ann-primary);
  font-size: 16px; font-weight: 700; font-style: normal;
}

/* ── Tag ── */
.sk-annotation-tag-row { padding: 8px 16px 0; }
.sk-annotation-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--sk-ann-primary);
  color: white;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

/* ── Input Group ── */
.sk-annotation-input-group { padding: 12px 16px 0; }
.sk-annotation-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--sk-ann-border);
  border-radius: var(--sk-ann-radius-sm);
  font-family: var(--sk-ann-font);
  font-size: 15px;       /* 16px prevents iOS zoom, 15px is close enough */
  line-height: 1.5;
  color: var(--sk-ann-text);
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--sk-ann-transition), box-shadow var(--sk-ann-transition);
  box-sizing: border-box;
  background: var(--sk-ann-bg);
  -webkit-appearance: none;  /* iOS fix */
}
.sk-annotation-textarea:focus {
  outline: none;
  border-color: var(--sk-ann-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.sk-annotation-textarea--error {
  border-color: var(--sk-ann-danger) !important;
  animation: sk-shake 0.4s ease;
}
@keyframes sk-shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.sk-annotation-char-count {
  font-size: 11px; color: var(--sk-ann-text-secondary);
  text-align: right; margin-top: 4px;
}

/* ── File Upload ── */
.sk-annotation-file-section { padding: 12px 16px 0; }
.sk-annotation-file-section label {
  font-size: 13px; font-weight: 600; color: var(--sk-ann-text);
}
.sk-annotation-file-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  background: var(--sk-ann-bg-soft);
  border: 1.5px dashed var(--sk-ann-border);
  border-radius: var(--sk-ann-radius-sm);
  cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--sk-ann-primary);
  transition: all var(--sk-ann-transition);
  min-height: 44px;      /* Touch-friendly */
}
.sk-annotation-file-trigger:hover,
.sk-annotation-file-trigger:active {
  background: var(--sk-ann-primary-light);
  border-color: var(--sk-ann-primary);
}
.sk-annotation-file-hint {
  display: block; font-size: 11px;
  color: var(--sk-ann-text-secondary); margin-top: 6px;
}

/* ── File Items ── */
.sk-annotation-file-list,
.sk-annotation-kept-files,
.sk-annotation-new-files { margin-top: 8px; }

.sk-annotation-file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--sk-ann-bg);
  border: 1px solid var(--sk-ann-border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  transition: all var(--sk-ann-transition);
  min-height: 44px;
}
.sk-annotation-file-item:hover { border-color: var(--sk-ann-primary); background: var(--sk-ann-bg-soft); }
.sk-annotation-file-icon { font-size: 18px; flex-shrink: 0; }
.sk-annotation-file-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--sk-ann-text); font-weight: 500;
}
.sk-annotation-file-size { font-size: 11px; color: var(--sk-ann-text-secondary); flex-shrink: 0; }
.sk-annotation-file-badge {
  font-size: 10px; padding: 2px 8px;
  background: var(--sk-ann-success-light); color: var(--sk-ann-success);
  border-radius: 10px; font-weight: 600; flex-shrink: 0;
}
.sk-annotation-file-remove {
  width: 28px; height: 28px;
  border: none;
  background: var(--sk-ann-danger-light); color: var(--sk-ann-danger);
  border-radius: 50%; cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--sk-ann-transition);
  min-width: 28px;
}
.sk-annotation-file-remove:hover,
.sk-annotation-file-remove:active {
  background: var(--sk-ann-danger); color: white;
  transform: scale(1.1);
}
.sk-annotation-empty-files {
  font-size: 12px; color: var(--sk-ann-text-secondary);
  font-style: italic; margin: 4px 0;
}

/* ── Actions ── */
.sk-annotation-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 16px 20px;          /* Extra bottom padding for safe area */
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.sk-annotation-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 20px;
  border: none; border-radius: var(--sk-ann-radius-sm);
  font-family: var(--sk-ann-font);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all var(--sk-ann-transition);
  min-height: 44px;
}
.sk-annotation-btn-cancel {
  background: var(--sk-ann-bg-soft); color: var(--sk-ann-text-secondary);
  border: 1px solid var(--sk-ann-border);
}
.sk-annotation-btn-cancel:hover { background: var(--sk-ann-border); color: var(--sk-ann-text); }
.sk-annotation-btn-save { background: var(--sk-ann-primary); color: white; }
.sk-annotation-btn-save:hover {
  background: var(--sk-ann-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.sk-annotation-btn-save:active { transform: translateY(0); }

/* ══════════════════════════════════════
   VIEW DIALOG — Bottom Sheet on Mobile
   ══════════════════════════════════════ */
.sk-annotation-dialog {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10001;
  font-family: var(--sk-ann-font);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.sk-annotation-dialog--visible {
  transform: translateY(0);
  pointer-events: all;
}
.sk-annotation-dialog-inner {
  background: var(--sk-ann-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--sk-ann-shadow-lg);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0;
}
.sk-annotation-dialog-inner::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--sk-ann-border);
  border-radius: 2px;
  margin: 10px auto 4px;
}
.sk-annotation-dialog-inner::-webkit-scrollbar { width: 5px; }
.sk-annotation-dialog-inner::-webkit-scrollbar-thumb { background: var(--sk-ann-border); border-radius: 3px; }

.sk-annotation-dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sk-ann-border);
  font-size: 14px; font-weight: 600; color: var(--sk-ann-text);
}
.sk-annotation-dialog-close {
  background: none; border: none;
  color: var(--sk-ann-text-secondary);
  cursor: pointer; padding: 8px; border-radius: 8px;
  display: flex;
  transition: all var(--sk-ann-transition);
  min-width: 40px; min-height: 40px;
}
.sk-annotation-dialog-close:hover { background: var(--sk-ann-bg-soft); }
.sk-annotation-dialog-tag {
  display: inline-block; margin: 12px 16px 0;
  padding: 3px 10px;
  background: var(--sk-ann-primary-light); color: var(--sk-ann-primary);
  border-radius: 20px; font-size: 11px; font-weight: 600;
  text-transform: capitalize;
}
.sk-annotation-dialog-text {
  padding: 12px 16px;
  font-size: 14px; line-height: 1.6;
  color: var(--sk-ann-text);
  white-space: pre-wrap;
}

/* ── Attachments in View ── */
.sk-annotation-dialog-attachments { padding: 0 16px 8px; }
.sk-annotation-dialog-attachments-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--sk-ann-text-secondary); margin-bottom: 8px;
}
.sk-annotation-dialog-attachment {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--sk-ann-bg-soft);
  border: 1px solid var(--sk-ann-border);
  border-radius: 8px; margin-bottom: 6px;
  text-decoration: none;
  color: var(--sk-ann-primary);
  font-size: 13px; font-weight: 500;
  transition: all var(--sk-ann-transition);
  min-height: 44px;
}
.sk-annotation-dialog-attachment:hover,
.sk-annotation-dialog-attachment:active {
  border-color: var(--sk-ann-primary);
  background: var(--sk-ann-primary-light);
}
.sk-annotation-dialog-thumb {
  width: 42px; height: 42px;
  object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.sk-annotation-dialog-file-icon { font-size: 22px; flex-shrink: 0; }
.sk-annotation-dialog-meta { padding: 0 16px 10px; font-size: 11px; color: var(--sk-ann-text-secondary); }

/* ── Dialog Actions ── */
.sk-annotation-dialog-actions {
  display: flex; gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--sk-ann-border);
}
.sk-annotation-dialog-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 10px 12px;
  border: none; border-radius: 8px;
  font-family: var(--sk-ann-font);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all var(--sk-ann-transition);
  min-height: 44px;
}
.sk-annotation-dialog-btn--edit {
  background: var(--sk-ann-success-light); color: var(--sk-ann-success);
}
.sk-annotation-dialog-btn--edit:hover,
.sk-annotation-dialog-btn--edit:active {
  background: var(--sk-ann-success); color: white;
}
.sk-annotation-dialog-btn--delete {
  background: var(--sk-ann-danger-light); color: var(--sk-ann-danger);
}
.sk-annotation-dialog-btn--delete:hover,
.sk-annotation-dialog-btn--delete:active {
  background: var(--sk-ann-danger); color: white;
}

/* ══════════════════════════════════════
   LOGIN PROMPT TOAST
   ══════════════════════════════════════ */
.sk-annotation-toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 10002;
  background: var(--sk-ann-text);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-family: var(--sk-ann-font);
  font-size: 13px;
  box-shadow: var(--sk-ann-shadow);
  display: flex; align-items: center; gap: 10px;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.sk-annotation-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}
.sk-annotation-toast-link {
  color: var(--sk-ann-highlight);
  font-weight: 600;
  text-decoration: none;
}
.sk-annotation-toast-link:hover { text-decoration: underline; }

/* ══════════════════════════════════════
   DESKTOP OVERRIDES (min-width: 640px)
   ══════════════════════════════════════ */
@media (min-width: 640px) {
  /* Modal → centered card instead of bottom sheet */
  .sk-annotation-modal {
    align-items: center;
  }
  .sk-annotation-panel {
    max-width: 460px;
    width: 92%;
    border-radius: var(--sk-ann-radius);
    transform: translateY(12px) scale(0.98);
  }
  .sk-annotation-modal--visible .sk-annotation-panel {
    transform: translateY(0) scale(1);
  }
  .sk-annotation-panel::before { display: none; }

  /* Dialog → centered card instead of bottom sheet */
  .sk-annotation-dialog {
    bottom: auto; left: 50%; right: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: auto;
  }
  .sk-annotation-dialog--visible {
    transform: translate(-50%, -50%) scale(1);
  }
  .sk-annotation-dialog-inner {
    max-width: 420px;
    width: 90vw;
    border-radius: var(--sk-ann-radius);
    max-height: 75vh;
  }
  .sk-annotation-dialog-inner::before { display: none; }

  /* Slightly larger padding on desktop */
  .sk-annotation-panel-header,
  .sk-annotation-selected-text,
  .sk-annotation-tag-row,
  .sk-annotation-input-group,
  .sk-annotation-file-section,
  .sk-annotation-actions {
    padding-left: 20px;
    padding-right: 20px;
  }
  .sk-annotation-dialog-header,
  .sk-annotation-dialog-tag,
  .sk-annotation-dialog-text,
  .sk-annotation-dialog-attachments,
  .sk-annotation-dialog-meta,
  .sk-annotation-dialog-actions {
    padding-left: 18px;
    padding-right: 18px;
  }
}