/* =============================================================================
 * BeautyAssist AI - 共通スタイル
 * 全ページで読み込まれる基底スタイル。色・余白・タイポグラフィを統一する。
 * ============================================================================= */

:root {
  --bg: #f4faec;
  --surface: #ffffff;
  --surface2: #e3f2d2;
  --surface3: #cfe7b3;
  --border: #c2dea0;
  --border-strong: #8cc665;
  --accent: #4eb13d;
  --accent2: #2a7a22;
  --accent-soft: #95d57c;
  --text: #15291f;
  --muted: #5b7a55;
  --error: #d65450;
  --error-bg: #fdf0ef;
  --success: #3aa334;
  --success-bg: #e9f6e6;
  --warning: #c98a2c;
  --warning-bg: #fef3df;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(30, 60, 25, 0.1);
  --shadow-lg: 0 8px 24px rgba(30, 60, 25, 0.18);
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Header ---------- */
.app-header {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-header .logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.app-header .brand {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 18px;
  color: var(--accent2);
  line-height: 1.1;
}

.app-header .brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.app-header .role-tag {
  margin-left: auto;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-header .logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  margin-left: 8px;
}

.app-header .logout-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ---------- Layout ---------- */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px;
}

.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
}

.page-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 24px;
  color: var(--accent2);
  margin-bottom: 4px;
}

.page-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.section h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 17px;
  color: var(--accent2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section h2 .section-meta {
  margin-left: auto;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.help-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 12px;
}

.row > .form-group {
  flex: 1;
}

@media (max-width: 600px) {
  .row {
    flex-direction: column;
    gap: 0;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-sub {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sub:hover {
  border-color: var(--accent);
  color: var(--accent2);
}

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

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- Badges & tags ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  background: var(--surface2);
  font-size: 11px;
  color: var(--accent2);
  font-weight: 500;
}

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

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

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

/* ---------- Alerts ---------- */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.6;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid #f0c4bf;
  color: #843a30;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid #c4e0cb;
  color: #2e7d4a;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid #f0d4a4;
  color: #7a4f22;
}

.alert-info {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ---------- Loading ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--muted);
  gap: 12px;
}

/* ---------- Lists / Cards ---------- */
.list-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface);
  transition: all 0.15s;
}

.list-item.clickable {
  cursor: pointer;
}

.list-item.clickable:hover {
  border-color: var(--accent);
  background: #fffdf8;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.list-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 3px;
}

.list-preview {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  max-width: 90vw;
}

.toast.show {
  opacity: 0.95;
}

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 10, 0.5);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal-bg.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 18px;
  color: var(--accent2);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 600px) {
  body {
    font-size: 14px;
  }
  .container,
  .container-narrow {
    padding: 16px 14px;
  }
  .section {
    padding: 16px;
  }
  .page-title {
    font-size: 21px;
  }
  .modal-bg {
    padding: 12px;
  }
}

/* ---------- Print ---------- */
@media print {
  .app-header,
  .btn,
  .modal-bg {
    display: none !important;
  }
  body {
    background: #fff;
  }
}
