/* =============================================
   北外记忆 - Apple Notes Style
   ============================================= */

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

:root {
  --bg-primary: #F5F5F7;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E8E8ED;
  --accent: #007AFF;
  --accent-hover: #0056CC;
  --text-primary: #1D1D1F;
  --text-secondary: #86868B;
  --border-color: #D2D2D7;
  --danger: #FF3B30;
  --success: #34C759;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* =============================================
   AUTH SECTION
   ============================================= */

#auth-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-hover);
  text-align: center;
}

.auth-logo {
  font-size: 56px;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.auth-panel h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.field {
  margin-bottom: 16px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.form-error {
  color: #FF3B30;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
  min-height: 0;
  padding: 8px 12px;
  background: rgba(255,59,48,0.1);
  border-radius: 8px;
  border: 1.5px solid rgba(255,59,48,0.4);
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  padding: 10px 20px;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
  padding: 6px 14px;
  font-size: 13px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Override .btn-primary/.btn-danger block display so .btn-sm works inline */
.btn-primary.btn-sm,
.btn.btn-primary.btn-sm {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto !important;
  padding: 6px 18px !important;
  font-size: 13px !important;
  gap: 6px;
}

.btn-danger.btn-sm,
.btn.btn-danger.btn-sm {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto !important;
  padding: 6px 18px !important;
  font-size: 13px !important;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #d32f2f;
}

.auth-switch {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* =============================================
   NOTES SECTION - LAYOUT
   ============================================= */

#notes-section {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.notes-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.app-logo {
  font-size: 22px;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.search-input {
  padding: 6px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  width: 180px;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
}

.notes-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */

.notes-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.btn-new-note {
  margin: 16px;
  width: auto;
  flex-shrink: 0;
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.note-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
  margin-bottom: 4px;
}

.note-item:hover {
  background: var(--bg-tertiary);
}

.note-item.active {
  background: rgba(0,122,255,0.1);
  border-left-color: var(--accent);
}

.note-item.pinned {
  border-left-color: #FF9500;
}

.note-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.note-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.note-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.note-item-tags {
  font-size: 11px;
  color: var(--accent);
  background: rgba(0,122,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

.note-item-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.note-item-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 32px 16px;
  line-height: 1.8;
}

/* =============================================
   NOTE EDITOR
   ============================================= */

.note-editor {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.no-note {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 15px;
  gap: 6px;
}

#note-editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.note-title-input {
  width: 100%;
  padding: 20px 28px 12px;
  border: none;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
}

.note-title-input::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 28px;
  border-bottom: 2px solid var(--border-color);
  flex-wrap: nowrap;
  overflow-x: auto;
  flex-shrink: 0;
}

.tags-input {
  padding: 5px 10px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  width: 200px;
  transition: border-color 0.2s;
}

.tags-input:focus {
  border-color: var(--accent);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-left: auto;
}

/* Always-visible toolbar action buttons */
.btn-save {
  background: var(--accent) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 20px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,122,255,0.3);
  flex-shrink: 0;
}
.btn-save:hover { background: var(--accent-hover) !important; }

.btn-cancel {
  background: rgba(134,134,139,0.15) !important;
  color: var(--text-secondary) !important;
  border: 1.5px solid var(--border-color) !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-cancel:hover { background: rgba(134,134,139,0.28) !important; }

.btn-delete-note {
  background: rgba(255,59,48,0.12) !important;
  color: #FF3B30 !important;
  border: 1.5px solid rgba(255,59,48,0.35) !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-delete-note:hover { background: rgba(255,59,48,0.22) !important; }

.pin-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.pin-label input {
  accent-color: #FF9500;
  width: 14px;
  height: 14px;
}

.note-content-input {
  flex: 1;
  padding: 16px 28px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.7;
}

/* =============================================
   TOAST
   ============================================= */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}

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

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* =============================================
   DARK MODE
   ============================================= */

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1C1C1E;
    --bg-secondary: #2C2C2E;
    --bg-tertiary: #3A3A3C;
    --text-primary: #F5F5F7;
    --text-secondary: #98989D;
    --border-color: #48484A;
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 700px) {
  .notes-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .notes-body {
    flex-direction: column;
  }

  .header-right {
    gap: 6px;
  }

  .search-input {
    width: 120px;
  }

  .note-title-input {
    font-size: 18px;
    padding: 16px 16px 10px;
  }

  .editor-toolbar {
    padding: 0 16px 10px;
  }

  .note-content-input {
    padding: 12px 16px;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

/* =============================================
   ADMIN BADGE & PANEL
   ============================================= */

.admin-badge {
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.admin-sidebar {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border-right: 2px solid #e94560;
}

.admin-panel-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #e94560;
  border-bottom: 1px solid rgba(233,69,96,0.3);
}

.admin-user-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.admin-user-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.admin-user-item:hover {
  background: rgba(233,69,96,0.15);
  border-color: rgba(233,69,96,0.3);
}

.admin-user-item.active {
  background: rgba(233,69,96,0.25);
  border-color: #e94560;
}

.admin-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.admin-user-meta {
  font-size: 11px;
  color: #888;
}

.admin-user-notes-count {
  display: inline-block;
  background: rgba(233,69,96,0.3);
  color: #e94560;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}

.note-user-label {
  padding: 4px 28px;
  font-size: 11px;
  color: #e94560;
  font-weight: 600;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  pointer-events: none;
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  pointer-events: auto;
}

.modal-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
}

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

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

@media (prefers-color-scheme: dark) {
  .admin-sidebar {
    background: linear-gradient(180deg, #0d0d1a 0%, #1a1a2e 100%);
  }
  .admin-user-name { color: #f5f5f7; }
}

/* =============================================
   ADMIN USER PANEL
   ============================================= */

#admin-user-panel {
  background: #1a1a2e;
  border-bottom: 2px solid #e94560;
}

.admin-user-panel-inner {
  max-width: 100%;
}

.admin-panel-title {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  color: #e94560;
  background: rgba(233,69,96,0.1);
  border-bottom: 1px solid rgba(233,69,96,0.2);
}

.admin-user-list {
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: #e94560 transparent;
}

.admin-user-item {
  flex-shrink: 0;
  width: 160px;
  background: #16213e;
  border: 1.5px solid rgba(233,69,96,0.2);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-user-item:hover {
  border-color: #e94560;
  background: rgba(233,69,96,0.1);
}

.admin-user-item.active {
  border-color: #e94560;
  background: rgba(233,69,96,0.2);
}

.admin-user-info {
  margin-bottom: 8px;
}

.admin-user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-count {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.admin-user-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-btn {
  width: 100%;
  padding: 5px 0;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-btn-view {
  background: rgba(0,122,255,0.2);
  color: #007AFF;
}

.admin-btn-view:hover {
  background: rgba(0,122,255,0.35);
}

.admin-btn-reset {
  background: rgba(255,149,0,0.2);
  color: #FF9500;
}

.admin-btn-reset:hover {
  background: rgba(255,149,0,0.35);
}

.admin-empty {
  padding: 16px;
  color: #888;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 700px) {
  #admin-user-panel {
    overflow-x: auto;
  }
  .admin-user-list {
    min-width: max-content;
  }
}

@media (prefers-color-scheme: dark) {
  #admin-user-panel { background: #0d0d1a; }
  .admin-user-item { background: #1a1a2e; }
}

.admin-btn-delete {
  background: rgba(255,59,48,0.15);
  color: #FF3B30;
}

.admin-btn-delete:hover {
  background: rgba(255,59,48,0.3);
}
