/*
 * ============================================================
 * ⚠️ WARNING: GLOBAL STYLESHEET - DO NOT EDIT LIGHTLY
 * ============================================================
 * このファイルは全ページ・全アプリで使用されています。
 * 
 * 編集前に必ずチェック:
 * 1. 変更理由を文書化
 * 2. 全ページで動作確認（ホーム、各アプリ、管理画面）
 * 3. レスポンシブデザイン確認（PC/タブレット/スマホ）
 * 4. 影響範囲をREADME.mdに記載してコミット
 * 
 * 詳細: README.md の「⚠️ 共通アセットファイルの編集について」参照
 * ============================================================
 */

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

:root {
  /* カラーパレット */
  --bg: #FAF7F0;
  --card-bg: #FFF9F0;
  --primary: #D4A574;
  --primary-hover: #C8A882;
  --secondary: #8B6F47;
  --heading: #8B6F47;
  --text: #5C4A3A;
  --text-light: #A58B6F;
  --border: #E8DCC8;
  --border-light: #E8D5C4;
  --white: #ffffff;
  --gray-light: #999;
  --gray-dark: #333;
  --black-alpha-50: rgba(0,0,0,0.5);
  --black-alpha-10: rgba(0,0,0,0.1);
  --primary-alpha-10: rgba(212, 165, 116, 0.1);
  --primary-alpha-15: rgba(212, 165, 116, 0.15);
  --primary-alpha-20: rgba(212, 165, 116, 0.2);
  
  /* スペーシング */
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* ボーダー半径 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 50%;
  
  /* シャドウ */
  --shadow-sm: 0 2px 4px var(--black-alpha-10);
  --shadow-md: 0 2px 6px var(--primary-alpha-10);
  --shadow-lg: 0 6px 16px var(--primary-alpha-20);
  --shadow-card: 0 2px 8px var(--primary-alpha-15);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic", "Hiragino Sans", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  /* スマホ操作性向上 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: normal;
  color: var(--heading);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* メインコンテンツ */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

main.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 2rem;
}

/* オフラインバナー */
.offline-banner {
  display: none;
  background: #8B6F47;
  color: #FFF9F0;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 400;
  flex-shrink: 0;
}

.offline-banner.visible {
  display: block;
}

/* ナビゲーション */
.navbar {
  background: var(--primary);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: normal;
  color: white;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 0.6625rem;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}

.nav-links #profile-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.nav-links .greeting-text {
  display: inline-block;
  vertical-align: middle;
  line-height: 32px;
}

.nav-links a {
  color: white;
  text-decoration: none;
  transition: opacity 0.3s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links a:hover {
  opacity: 0.8;
}

/* セクション */
section {
  margin-bottom: 2.5rem;
  padding: 0 2rem;
}

section h2 {
  font-size: 1.5rem;
  color: var(--heading);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

section p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

section ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

section ul li {
  margin-bottom: 0.5rem;
}

/* ヒーローセクション */
.hero {
  text-align: center;
  padding: 3rem 0;
  background: var(--card-bg);
  margin: 2rem 0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(212, 165, 116, 0.15);
}

.hero h2 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--heading);
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-light);
}

/* アプリグリッド */
.apps-grid {
  margin: 0;
  padding-top: 1rem;
}

.apps-grid h3 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.app-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 6px rgba(212, 165, 116, 0.1);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(212, 165, 116, 0.2);
  border-color: var(--primary);
}

.app-card h4 {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--heading);
  line-height: 1.3;
}

.app-card p {
  color: var(--text-light);
  font-size: 0.75rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
}

.modal.hidden {
  display: none;
}

.modal:not(.hidden) {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--white);
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-light);
}

.close:hover {
  color: var(--gray-dark);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  /* 入力フィールドはテキスト選択可能 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.modal-content button {
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s;
}

.modal-content button:hover {
  background: var(--primary-hover);
}

/* プロフィールモーダル専用スタイル */
.profile-modal-content {
  max-width: 400px;
}

.btn-logout {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s;
  font-family: 'Zen Maru Gothic', sans-serif;
}

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

.btn-google-login {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0;
  background: white;
  color: #5C4A3A;
  border: 1px solid #E8DCC8;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Zen Maru Gothic', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-google-login:hover {
  background: #FAF7F0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-twitter-login {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0;
  background: #000000;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s;
  font-family: 'Zen Maru Gothic', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-twitter-login:hover {
  background: #1a1a1a;
}

.btn-google-signin {
  width: 100%;
  padding: 0.75rem;
  background: white;
  color: #5C4A3A;
  border: 1px solid #E8DCC8;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Zen Maru Gothic', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-google-signin:hover {
  background: #FAF7F0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-light);
}

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

.form-footer a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* フォーム要素 - テキスト選択可能 */
input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* レスポンシブ（モバイル） */
@media (max-width: 767px) {
  .container {
    padding: 0 8px;
  }
  
  main.container {
    padding: 0 8px 2rem;
  }
  
  .navbar .container {
    padding: 0 8px;
    flex-direction: row;
    justify-content: space-between;
  }
  
  .logo-container {
    gap: 0.5rem;
  }
  
  .logo-icon {
    width: 32px;
    height: 32px;
  }
  
  .logo {
    font-size: 1.2rem;
  }
  
  .nav-links {
    gap: 0.75rem;
    flex-shrink: 1;
    min-width: 0;
  }
  
  .nav-links a,
  .nav-links span {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* スマホでは「こんにちは、〇〇さん」を非表示 */
  .greeting-text {
    display: none !important;
  }
  
  #auth-section .greeting-text {
    display: none !important;
  }
  
  /* スマホではアプリカードの説明文を非表示 */
  .app-card p {
    display: none;
  }
  
  section h2 {
    font-size: 1.25rem;
  }
  
  section {
    padding: 0 1rem;
  }
  
  section p, section ul {
    font-size: 0.95rem;
  }

  .hero h2 {
    font-size: 2rem;
  }
  
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
  
  /* aboutページなど、コンテンツページのグリッドはモバイルで1列に */
  main.container section .grid {
    grid-template-columns: 1fr;
  }
  
  /* ホームページのアプリグリッドは3列を維持 */
  .apps-grid .grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  
  .app-card {
    padding: 0.5rem;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  
  .app-card:hover {
    transform: scale(1.05);
    box-shadow: none;
    border: none;
    background: transparent;
  }
}

/* Google Material Icons */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
}

/* ========================================
   共通コンポーネント
   ======================================== */

/* フォーム要素 */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: normal;
  color: var(--heading);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.3s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.help-text {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* フォームエラー */
.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
  border-color: #DC3545;
}

.error-message {
  color: #DC3545;
  font-size: 12px;
  margin-top: 4px;
}

/* テーブル */
.data-table {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--secondary);
  color: var(--white);
  padding: var(--spacing-md);
  text-align: left;
  font-weight: normal;
}

.data-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: var(--primary-alpha-10);
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: normal;
}

.badge-admin {
  background: var(--secondary);
  color: var(--white);
}

.badge-staff {
  background: #A8926F;
  color: var(--white);
}

.badge-user {
  background: var(--border);
  color: var(--heading);
}

.badge-success {
  background: #D4E8D4;
  color: #2E5C2E;
}

.badge-error {
  background: #F8D7DA;
  color: #721C24;
}

.badge-warning {
  background: #FFF3CD;
  color: #856404;
}

.badge-info {
  background: var(--primary-alpha-15);
  color: var(--heading);
}

/* ボタン */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 14px;
  font-weight: normal;
  transition: opacity 0.3s, transform 0.2s;
  border: none;
}

.btn:hover {
  opacity: 0.9;
}

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

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

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

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

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-text {
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
}

.btn-text:hover {
  background: var(--primary-alpha-10);
}

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

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
  display: block;
}

/* アラート */
.alert {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.alert .material-symbols-outlined {
  font-size: 20px;
}

.alert-success {
  background: #D4E8D4;
  color: #2E5C2E;
  border: 1px solid #A8D4A8;
}

.alert-error {
  background: #F8D7DA;
  color: #721C24;
  border: 1px solid #F5C6CB;
}

.alert-warning {
  background: #FFF3CD;
  color: #856404;
  border: 1px solid #FFEAA7;
}

.alert-info {
  background: var(--primary-alpha-15);
  color: var(--heading);
  border: 1px solid var(--border-light);
}

/* スピナー */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl);
}

.loading p {
  color: var(--text-light);
  font-size: 14px;
}

/* ========================================
   管理画面用カードコンポーネント
   ======================================== */

/* カードリスト（モバイル用） */
.admin-card-list {
  display: none;
}

.admin-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border);
  transition: box-shadow 0.3s;
}

.admin-card:hover {
  box-shadow: var(--shadow-md);
}

.admin-card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.admin-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.admin-card-info {
  flex: 1;
  min-width: 0;
}

.admin-card-name {
  font-size: 16px;
  font-weight: normal;
  color: var(--heading);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-card-meta {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  align-items: center;
}

.admin-card-actions {
  margin-top: var(--spacing-sm);
  display: flex;
  gap: var(--spacing-sm);
}

.admin-card-actions .btn {
  flex: 1;
}

/* テーブル/カード切り替え */
.admin-table-container {
  display: block;
}

/* ========================================
   レスポンシブ: テーブル
   ======================================== */
@media (max-width: 767px) {
  /* テーブルをカードに切り替え */
  .admin-table-container {
    display: none;
  }
  
  .admin-card-list {
    display: block;
  }
  
  /* 汎用テーブルのレスポンシブ（data-table） */
  .data-table table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }
  
  .data-table thead {
    display: none;
  }
  
  .data-table tr {
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  
  .data-table td {
    position: relative;
    padding-left: 40%;
    border-bottom: 1px solid var(--border-light);
  }
  
  .data-table td:before {
    content: attr(data-label);
    position: absolute;
    left: var(--spacing-md);
    font-weight: normal;
    color: var(--heading);
  }
  
  .data-table td:last-child {
    border-bottom: none;
  }
}

/* ========================================
   アプリタイトルヘッダー（共通コンポーネント）
   ======================================== */

.app-title-header {
  text-align: left;
  margin-bottom: 2rem;
  margin-top: 12px;
}

/* タブナビゲーションが直後にある場合、隙間を詰める */
.app-title-header:has(+ .tab-navigation) {
  margin-bottom: 0;
}

.app-title-header h1 {
  color: var(--heading);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.app-title-header h1 img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.app-title-text-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-title-main {
  font-size: 1.5rem;
  color: var(--heading);
  line-height: 1;
}

.app-title-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  font-weight: 400;
  line-height: 1.3;
}

.app-icon-wrapper {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FEF6E7;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.app-icon-circle {
  width: 32px;
  height: 32px;
  border: 1.5px solid #976334;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-icon-circle .material-symbols-outlined {
  font-size: 20px;
  color: #976334;
}

/* フッター */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  margin-top: 2rem;
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-copyright {
  color: var(--text-light);
  font-size: 0.8rem;
}

/* レスポンシブ対応 */
@media (max-width: 767px) {
  .app-title-main {
    font-size: 1.2rem;
  }
  
  .app-title-subtitle {
    font-size: 0.75rem;
  }
  
  footer {
    margin-top: 1.5rem;
    padding: 1rem 0;
  }
  
  .footer-links {
    gap: 1rem;
  }
  
  .footer-links a {
    font-size: 0.8rem;
  }
  
  .footer-copyright {
    font-size: 0.75rem;
  }
}
