/**
 * 共通スタイルシート
 *
 * すべてのページで使用される共通スタイル
 * - リセットCSS
 * - レイアウト
 * - コンポーネント（ボタン、フォーム、アラート等）
 * - レスポンシブデザイン
 */

/* ==========================================
   リセットCSS
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
  min-height: 100vh;
}

/* ==========================================
   レイアウト
   ========================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

.container-sm {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 32px;
}

.container-md {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ==========================================
   ヘッダー
   ========================================== */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-username {
  font-size: 1rem;
}

.header-logout {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.header-logout:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================
   メインコンテンツ
   ========================================== */
.main-content {
  padding: 40px 0;
  min-height: calc(100vh - 200px);
}

/* ==========================================
   カード
   ========================================== */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  padding: 32px;
  margin-bottom: 24px;
}

.card-header {
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
}

.card-body {
  padding: 0;
}

/* ==========================================
   フォーム
   ========================================== */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #444;
  font-size: 0.95rem;
}

.form-label.required::after {
  content: " *";
  color: #e53e3e;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: #e53e3e;
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

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

.form-help {
  display: block;
  margin-top: 6px;
  font-size: 0.875rem;
  color: #718096;
}

.field-error-message {
  display: block;
  margin-top: 6px;
  font-size: 0.875rem;
  color: #e53e3e;
}

/* チェックボックス */
.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.form-checkbox {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: #667eea;
  flex-shrink: 0;
}

.checkbox-label {
  font-size: 0.95rem;
  color: #444;
  cursor: pointer;
  line-height: 1.6;
  user-select: none;
}

.privacy-policy-link {
  color: #667eea;
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s ease;
}

.privacy-policy-link:hover {
  color: #764ba2;
}

/* ==========================================
   ボタン
   ========================================== */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.btn:disabled,
.btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover:not(:disabled):not(.loading) {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.btn-secondary:hover:not(:disabled):not(.loading) {
  background: #f8f9ff;
  transform: translateY(-2px);
}

.btn-success {
  background: #48bb78;
  color: white;
}

.btn-success:hover:not(:disabled):not(.loading) {
  background: #38a169;
  transform: translateY(-2px);
}

.btn-danger {
  background: #e53e3e;
  color: white;
}

.btn-danger:hover:not(:disabled):not(.loading) {
  background: #c53030;
  transform: translateY(-2px);
}

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

.btn-lg {
  padding: 16px 36px;
  font-size: 1.125rem;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* ==========================================
   アラート・メッセージ
   ========================================== */
.alert {
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-success {
  background: #f0fdf4;
  border-left: 4px solid #48bb78;
  color: #22543d;
}

.alert-success::before {
  content: "✓";
  color: #48bb78;
  font-weight: bold;
  font-size: 1.2rem;
}

.alert-error {
  background: #fff5f5;
  border-left: 4px solid #e53e3e;
  color: #742a2a;
}

.alert-error::before {
  content: "✕";
  color: #e53e3e;
  font-weight: bold;
  font-size: 1.2rem;
}

.alert-warning {
  background: #fffaf0;
  border-left: 4px solid #ed8936;
  color: #7c2d12;
}

.alert-warning::before {
  content: "⚠";
  color: #ed8936;
  font-weight: bold;
  font-size: 1.2rem;
}

.alert-info {
  background: #ebf8ff;
  border-left: 4px solid #4299e1;
  color: #2c5282;
}

.alert-info::before {
  content: "ⓘ";
  color: #4299e1;
  font-weight: bold;
  font-size: 1.2rem;
}

/* ==========================================
   グリッドシステム
   ========================================== */
.grid {
  display: grid;
  gap: 24px;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* ==========================================
   ユーティリティクラス
   ========================================== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mt-5 { margin-top: 40px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.mb-5 { margin-bottom: 40px; }

.hidden {
  display: none !important;
}

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}

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

/* ==========================================
   フッター
   ========================================== */
.footer {
  background: #2d3748;
  color: #cbd5e0;
  padding: 32px 0;
  text-align: center;
  margin-top: 60px;
}

.footer-content {
  font-size: 0.875rem;
}

.footer-link {
  color: #667eea;
  text-decoration: none;
  margin: 0 12px;
}

.footer-link:hover {
  text-decoration: underline;
}

/* ==========================================
   レスポンシブデザイン
   ========================================== */

/* タブレット */
@media (max-width: 1023px) {
  .container {
    padding: 0 24px;
  }

  .container-sm,
  .container-md {
    padding: 0 24px;
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* モバイル */
@media (max-width: 767px) {
  html {
    font-size: 14px;
  }

  .container,
  .container-sm,
  .container-md {
    padding: 0 16px;
  }

  .header-content {
    flex-direction: column;
    gap: 16px;
  }

  .header-user {
    width: 100%;
    justify-content: space-between;
  }

  .card {
    padding: 24px 20px;
  }

  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 24px 0;
  }

  .btn {
    padding: 14px 24px;
  }
}
