/* ===========================
   Easy AI for Dentists — Shared App Styles
   Design: Light mode, Notion-meets-Linear
   =========================== */

:root {
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --primary-hover: #1D4ED8;
  --primary-dark: #1E40AF;
  --bg: #FFFFFF;
  --surface: #F9FAFB;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --error: #DC2626;
  --error-bg: #FEF2F2;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.75rem; letter-spacing: -0.5px; }
h2 { font-size: 1.35rem; letter-spacing: -0.3px; }
h3 { font-size: 1.1rem; }

/* ===== APP NAV ===== */
.app-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.app-nav .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
}

.app-nav .logo-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.app-nav .logo-text span {
  color: var(--text-secondary);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface);
}

.nav-links .btn-logout {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: inherit;
}

.nav-links .btn-logout:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* ===== LAYOUT ===== */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

.app-container-wide {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h2 {
  margin-bottom: 4px;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== BANNERS ===== */
.banner {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.banner-warning {
  background: var(--warning-bg);
  border: 1px solid #FDE68A;
  color: #92400E;
}

.banner-info {
  background: var(--primary-light);
  border: 1px solid #BFDBFE;
  color: var(--primary-dark);
}

.banner-success {
  background: var(--success-bg);
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.banner-error {
  background: var(--error-bg);
  border: 1px solid #FECACA;
  color: #991B1B;
}

.banner a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

/* ===== TOOL GRID ===== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  cursor: pointer;
  display: block;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.tool-card .tool-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.tool-card h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.tool-card p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group label .optional {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: 36px;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-error-msg {
  color: var(--error);
  font-size: 0.82rem;
  margin-top: 4px;
  display: none;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--text-tertiary);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #FECACA;
}

.btn-danger:hover:not(:disabled) {
  background: #FEE2E2;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 0.95rem;
}

/* ===== OUTPUT AREA ===== */
.output-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  min-height: 200px;
  white-space: pre-wrap;
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
  position: relative;
}

.output-placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

.output-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Pulsing skeleton */
.skeleton {
  display: none;
}

.skeleton.active {
  display: block;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 10px;
}

.skeleton-line:nth-child(1) { width: 100%; }
.skeleton-line:nth-child(2) { width: 85%; }
.skeleton-line:nth-child(3) { width: 92%; }
.skeleton-line:nth-child(4) { width: 70%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== OUTPUT HISTORY ITEMS ===== */
.output-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
}

.output-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.output-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.output-item-tool {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.output-item-date {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.output-item-content {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.output-item-content.expanded {
  max-height: none;
}

.output-item-content::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg));
}

.output-item-content.expanded::after {
  display: none;
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 24px;
}

.auth-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
  text-decoration: none;
}

.auth-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}

.auth-logo .logo-text {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.auth-logo .logo-text span {
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-title {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.4rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

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

.auth-error {
  background: var(--error-bg);
  border: 1px solid #FECACA;
  color: var(--error);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 320px;
  margin: 0 auto;
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.1rem;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-green {
  background: var(--success-bg);
  color: var(--success);
}

.badge-yellow {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-nav {
    padding: 0 16px;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-links a {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .app-container, .app-container-wide {
    padding: 20px 16px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

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

  .output-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ===== UTILITIES ===== */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-secondary); }
.hidden { display: none !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
