/**
 * Alpha Control shared component baseline.
 *
 * This file defines the *default* look-and-feel for shared component classes
 * (.btn / .toast / .modal / .field-*) so new pages do not have to redefine
 * them. It is intentionally non-aggressive: existing pages that ship their
 * own inline <style> for the same class names load AFTER this file and will
 * win the cascade, so adopting this stylesheet should not change any current
 * page visually.
 *
 * Tokens come from tokens.css. Theme colors come from each page's own
 * [data-theme="..."] block.
 */

/* ── base reset ──────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

body {
  font-family: 'Microsoft YaHei', '微软雅黑', 'PingFang SC', 'Segoe UI', system-ui, sans-serif;
  font-size: var(--font-size-md, 14px);
  background: var(--bg);
  color: var(--text);
}

/* ── focus rings ─────────────────────────────────── */
.ac-focus-ring,
button:focus-visible,
a:focus-visible,
[role="tab"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn,
.ac-btn {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 6px);
  padding: 6px 12px;
  font-size: var(--font-size-base, 13px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.3;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover,
.ac-btn:hover { opacity: 0.85; }
.btn:disabled,
.ac-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm,
.ac-btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-sm, 11px);
}

.btn-ghost,
.ac-btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover,
.ac-btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface2);
  opacity: 1;
}

.btn-danger,
.ac-btn-danger {
  background: #ef4444;
  color: #fff;
}
.btn-danger:hover,
.ac-btn-danger:hover {
  background: #dc2626;
  opacity: 1;
}

.btn-danger-ghost,
.ac-btn-danger-ghost {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
}
.btn-danger-ghost:hover,
.ac-btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.1);
  opacity: 1;
}

/* ── Toast ───────────────────────────────────────── */
.ac-toast {
  position: fixed;
  right: var(--space-5, 20px);
  bottom: var(--space-5, 20px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 10px 16px;
  font-size: var(--font-size-base, 13px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: var(--z-toast, 400);
}
.ac-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .ac-toast {
    left: var(--space-3, 12px);
    right: var(--space-3, 12px);
    bottom: var(--space-3, 12px);
  }
}

/* ── Modal ───────────────────────────────────────── */
.ac-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  z-index: var(--z-modal, 200);
}

.ac-modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  padding: var(--space-6, 24px);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.ac-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 16px);
}

.ac-modal-title {
  font-size: var(--font-size-md, 14px);
  font-weight: 800;
  color: var(--accent);
}

.ac-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  transition: background 0.15s, color 0.15s;
}
.ac-modal-close:hover {
  background: var(--surface2);
  color: var(--text);
}

@media (max-width: 600px) {
  .ac-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .ac-modal {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    border-radius: var(--radius-xl, 14px) var(--radius-xl, 14px) 0 0;
  }
}

/* ── Form fields ─────────────────────────────────── */
.ac-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ac-field-label {
  font-size: var(--font-size-sm, 11px);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.ac-field-input,
.ac-field input,
.ac-field select,
.ac-field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  color: var(--text);
  font-size: var(--font-size-base, 13px);
  font-family: inherit;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ac-field-input:focus,
.ac-field input:focus,
.ac-field select:focus,
.ac-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(0,128,204,0.12));
}

.ac-field-error {
  display: none;
  font-size: var(--font-size-xs, 10px);
  color: #ef4444;
  margin-top: 2px;
}
.ac-field.has-error .ac-field-error {
  display: block;
}
.ac-field.has-error input,
.ac-field.has-error select,
.ac-field.has-error textarea {
  border-color: #ef4444;
}

/* ── Skeleton placeholders ──────────────────────── */
@keyframes ac-skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.ac-skeleton {
  display: block;
  background:
    linear-gradient(
      90deg,
      var(--surface2, rgba(127, 127, 127, 0.10)) 0%,
      var(--border, rgba(127, 127, 127, 0.22)) 50%,
      var(--surface2, rgba(127, 127, 127, 0.10)) 100%
    );
  background-size: 200% 100%;
  border-radius: var(--radius-sm, 6px);
  animation: ac-skeleton-shimmer 1.4s ease-in-out infinite;
  color: transparent;
  user-select: none;
}
.ac-skeleton-text {
  height: 0.85em;
  margin: 6px 0;
  border-radius: var(--radius-xs, 4px);
}
.ac-skeleton-title {
  height: 1.2em;
  width: 60%;
  margin: 8px 0 12px;
}
.ac-skeleton-block {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-md, 8px);
}
.ac-skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  margin-bottom: var(--space-3, 12px);
}

@media (prefers-reduced-motion: reduce) {
  .ac-skeleton {
    animation: none;
  }
}

/* Shared polish layer.
   These selectors are intentionally a little more specific than legacy page
   rules so repeated controls converge even when pages define local styles. */
::selection {
  background: var(--accent-dim, rgba(0, 128, 204, 0.14));
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.btn.btn,
.ac-btn.ac-btn,
.primary-button.primary-button {
  min-height: var(--control-height-md, 36px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 6px);
  background: var(--accent);
  color: #fff;
  font-size: var(--font-size-base, 13px);
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm, none);
  transition:
    background var(--motion-fast, 0.15s),
    border-color var(--motion-fast, 0.15s),
    box-shadow var(--motion-fast, 0.15s),
    color var(--motion-fast, 0.15s),
    opacity var(--motion-fast, 0.15s),
    transform var(--motion-fast, 0.15s);
}

.btn.btn:hover,
.ac-btn.ac-btn:hover,
.primary-button.primary-button:hover {
  opacity: 0.92;
  box-shadow: var(--shadow-md, var(--glow, none));
  transform: translateY(-1px);
}

.btn.btn:disabled,
.ac-btn.ac-btn:disabled,
.primary-button.primary-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn.btn-sm,
.ac-btn.ac-btn-sm {
  min-height: var(--control-height-sm, 30px);
  padding: 5px 10px;
  font-size: var(--font-size-sm, 11px);
}

.btn.btn-ghost,
.ac-btn.ac-btn-ghost,
.ghost-button.ghost-button {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  box-shadow: none;
}

.btn.btn-ghost:hover,
.ac-btn.ac-btn-ghost:hover,
.ghost-button.ghost-button:hover {
  border-color: var(--accent);
  background: var(--surface-hover, var(--surface2));
  color: var(--text);
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(0, 128, 204, 0.12));
}

.btn.btn-danger,
.ac-btn.ac-btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn.btn-danger-ghost,
.ac-btn.ac-btn-danger-ghost,
.ghost-button.ghost-button.danger {
  background: transparent;
  border-color: #ef4444;
  color: #ef4444;
}

.btn.btn-danger-ghost:hover,
.ac-btn.ac-btn-danger-ghost:hover,
.ghost-button.ghost-button.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.panel-nav.panel-nav-icons,
.panel-nav,
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.panel-nav.panel-nav-icons::-webkit-scrollbar,
.panel-nav::-webkit-scrollbar,
.nav-links::-webkit-scrollbar {
  display: none;
}

.panel-nav.panel-nav-icons .panel-nav-icon,
.panel-nav .panel-nav-icon,
.nav-links a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill, 9999px);
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
  background: color-mix(in srgb, var(--surface) 56%, transparent);
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: var(--font-size-sm, 11px);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background var(--motion-fast, 0.15s),
    border-color var(--motion-fast, 0.15s),
    box-shadow var(--motion-fast, 0.15s),
    color var(--motion-fast, 0.15s),
    transform var(--motion-fast, 0.15s);
}

.panel-nav.panel-nav-icons .panel-nav-icon:hover,
.panel-nav.panel-nav-icons .panel-nav-icon.active,
.panel-nav .panel-nav-icon:hover,
.panel-nav .panel-nav-icon.active,
.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 62%, var(--border));
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-dim) 72%, transparent);
  transform: translateY(-1px);
}

.ac-field-input,
.ac-field input,
.ac-field select,
.ac-field textarea,
.form-input.form-input,
.settings-input.settings-input,
.pane-input.pane-input,
textarea,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
select {
  min-height: var(--control-height-md, 36px);
  border-radius: var(--radius-sm, 6px);
  transition:
    background var(--motion-fast, 0.15s),
    border-color var(--motion-fast, 0.15s),
    box-shadow var(--motion-fast, 0.15s);
}

.ac-field-input:focus,
.ac-field input:focus,
.ac-field select:focus,
.ac-field textarea:focus,
.form-input.form-input:focus,
.settings-input.settings-input:focus,
.pane-input.pane-input:focus,
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(0, 128, 204, 0.12));
}

.modal-overlay.modal-overlay,
.calendar-editor-backdrop,
.item-editor-backdrop,
.editor-backdrop,
.dialog-backdrop {
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal.modal,
.ac-modal.ac-modal,
.calendar-editor,
.item-editor-card,
.editor-card,
.dialog-card {
  border-color: color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: var(--radius-lg, 10px);
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.18));
}

.toast.toast,
.ac-toast.ac-toast,
.unified-toast.unified-toast {
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--accent) 18%);
  border-radius: var(--radius-md, 8px);
  background: color-mix(in srgb, var(--surface) 94%, var(--bg));
  color: var(--text);
  box-shadow: var(--shadow-lg, 0 14px 38px rgba(0, 0, 0, 0.2));
}

.tag-chip,
.summary-chip,
.account-pill,
.project-badge,
.event-detail-source,
.event-row-meta span,
.event-row-tags span,
.event-detail-tags span,
.calendar-editor-meta span,
.resource-tag-row span {
  border-radius: var(--radius-pill, 9999px);
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: color-mix(in srgb, var(--surface2) 74%, var(--surface));
  color: var(--text-muted);
}

.section.section,
.card.card,
.reading-card,
.event-chart-panel,
.event-timeline,
.event-detail,
.calendar-board,
.calendar-toolbar,
.calendar-filter-row,
.project-row,
.item-row,
.agg-event-row,
.agg-todo-row,
.model-config-card {
  border-color: color-mix(in srgb, var(--border) 88%, transparent);
  box-shadow: var(--shadow-sm, none);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

body h1,
body h2,
body h3,
.section-title.section-title,
.ep-section-label.ep-section-label,
.form-label.form-label,
.field-label.field-label,
.sec-label.sec-label {
  letter-spacing: 0;
}

body header {
  border-color: color-mix(in srgb, var(--border) 84%, transparent);
  box-shadow: var(--shadow-sm, none);
}

body .reading-card,
body .endpoint,
body .auth-box,
body .locked-box,
body .node-attachment-card,
body .modal-idea-item {
  border-color: color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-sm, none);
}

body .reading-card {
  transition:
    border-color var(--motion-fast, 0.15s),
    box-shadow var(--motion-fast, 0.15s),
    transform var(--motion-fast, 0.15s);
}

body .reading-card:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
}

body .reading-card-tag,
body .tab-badge,
body .modal-ideas-count {
  border-radius: var(--radius-pill, 9999px);
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

body .filter-panel,
body .mobile-search-popover {
  border-color: color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
}

body .btn-icon,
body .card-action-btn,
body .opt-btn,
body .tab-select-trigger,
body .tab-dropdown-item {
  border-radius: var(--radius-sm, 6px);
  transition:
    background var(--motion-fast, 0.15s),
    border-color var(--motion-fast, 0.15s),
    box-shadow var(--motion-fast, 0.15s),
    color var(--motion-fast, 0.15s),
    transform var(--motion-fast, 0.15s);
}

body .btn-icon:hover,
body .card-action-btn:hover,
body .opt-btn:hover,
body .tab-select-trigger:hover,
body .tab-dropdown-item:hover {
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(0, 128, 204, 0.12));
  transform: translateY(-1px);
}
