/* リセットと基本スタイル */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

/* ログインページ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.login-box {
  background: white;
  padding: 40px 30px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  text-align: center;
  color: #1e3a8a;
  margin-bottom: 10px;
  font-size: 26px;
  font-weight: 700;
}

.login-box h2 {
  text-align: center;
  color: #64748b;
  margin-bottom: 30px;
  font-size: 16px;
  font-weight: 500;
}

.login-info {
  margin-top: 30px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 5px;
  font-size: 12px;
  color: #666;
}

.login-info p {
  margin: 5px 0;
}

/* ヘッダー */
.header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  padding: 15px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.header-title h1 {
  font-size: 20px;
  font-weight: 600;
}

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

.user-name {
  font-weight: 600;
}

.user-role {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-size: 12px;
}

/* コンテナ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ページヘッダー */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.page-header h1 {
  font-size: 24px;
  color: #333;
}

/* ナビゲーションタブ */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 5px;
}

.nav-tabs a {
  padding: 10px 20px;
  background: white;
  border-radius: 5px;
  text-decoration: none;
  color: #666;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.3s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.nav-tabs a:hover {
  background: #f0f0f0;
}

.nav-tabs a.active {
  background: #3b82f6;
  color: white;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="month"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #999;
  font-size: 13px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.required {
  color: #e74c3c;
}

.expense-form {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
  flex-wrap: wrap;
}

/* フィルターボックス */
.filter-box {
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

/* ボタン */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: all 0.3s;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-success:hover {
  background: #229954;
}

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

.btn-danger:hover {
  background: #c0392b;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 16px;
  font-size: 14px;
}

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

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

.btn-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

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

/* 申請カード */
.expense-list {
  display: grid;
  gap: 15px;
}

.expense-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.expense-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.expense-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  flex-wrap: wrap;
  gap: 10px;
}

.expense-date {
  color: #666;
  font-size: 14px;
  margin-left: 10px;
}

.expense-body {
  padding: 15px;
}

.expense-route {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.expense-amount {
  font-size: 24px;
  color: #3b82f6;
  margin: 10px 0;
}

.expense-purpose {
  color: #666;
  margin: 10px 0;
  font-size: 14px;
}

.expense-details {
  display: flex;
  gap: 15px;
  margin: 10px 0;
  font-size: 14px;
  color: #666;
  flex-wrap: wrap;
}

.expense-receipt {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* バッジ */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

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

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

.badge-secondary {
  background: #e9ecef;
  color: #6c757d;
}

.status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

.status-approved {
  background: #d4edda;
  color: #155724;
}

.status-rejected {
  background: #f8d7da;
  color: #721c24;
}

/* サマリーカード */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.summary-card {
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.summary-label {
  color: #666;
  font-size: 14px;
  margin-bottom: 10px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: #3b82f6;
}

/* テーブル */
.section {
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.section h2 {
  margin-bottom: 20px;
  font-size: 20px;
  color: #333;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
}

.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

.data-table .amount {
  text-align: right;
  font-weight: 600;
}

.data-table .center {
  text-align: center;
}

.total-row {
  background: #f8f9fa;
  font-weight: 600;
}

/* メッセージ */
.error-message {
  background: #f8d7da;
  color: #721c24;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  border-left: 4px solid #f5c6cb;
}

.success-message {
  background: #d4edda;
  color: #155724;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  border-left: 4px solid #c3e6cb;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state p {
  font-size: 16px;
}

/* レスポンシブデザイン（スマホ対応） */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .header-title h1 {
    font-size: 18px;
  }

  .header-user {
    font-size: 14px;
  }

  .nav-tabs {
    gap: 5px;
  }

  .nav-tabs a {
    padding: 8px 15px;
    font-size: 14px;
  }

  .expense-form {
    padding: 20px;
  }

  .expense-route {
    font-size: 16px;
  }

  .expense-amount {
    font-size: 20px;
  }

  .summary-value {
    font-size: 24px;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  .btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons form {
    flex: 1;
  }

  .action-buttons .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .login-box {
    padding: 30px 20px;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .expense-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .data-table th,
  .data-table td {
    padding: 6px;
    font-size: 11px;
  }
}

/* モダンUIの追加スタイル */

/* トースト通知システム */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  background: white;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease-out;
  border-left: 4px solid #3b82f6;
  min-width: 300px;
}

.toast.toast-success {
  border-left-color: #27ae60;
}

.toast.toast-error {
  border-left-color: #e74c3c;
}

.toast.toast-warning {
  border-left-color: #f39c12;
}

.toast.toast-info {
  border-left-color: #3498db;
}

.toast-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

.toast-message {
  font-size: 14px;
  color: #666;
}

.toast-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.toast-close:hover {
  background: #f0f0f0;
  color: #333;
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast.removing {
  animation: slideOutRight 0.3s ease-in;
}

/* ボタンのマイクロインタラクション */
.btn {
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

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

/* ローディングスピナー（モダン） */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* カードホバーエフェクト強化 */
.expense-card,
.summary-card,
.section {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expense-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.15);
}

/* フォーカス状態の改善 */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* スムーズなページ遷移 */
.page-transition {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* スケルトンローディング */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

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

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

/* アイコンボタン */
.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
}

.icon-btn:hover {
  transform: rotate(90deg) scale(1.1);
}

/* フローティングアクションボタン */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

/* モーダルダイアログ（モダン） */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* プログレスバー */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1e3a8a);
  border-radius: 4px;
  transition: width 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* チップ/タグ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0f0f0;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  transition: all 0.2s;
}

.chip:hover {
  background: #e0e0e0;
}

.chip-removable {
  cursor: pointer;
}

.chip-remove {
  background: none;
  border: none;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-remove:hover {
  background: #ccc;
}

/* ツールチップ */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  background: #333;
  color: white;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip .tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* レスポンシブ調整（モバイル） */
@media (max-width: 768px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .toast {
    min-width: auto;
  }

  .fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .modal-content {
    padding: 24px;
    border-radius: 12px;
  }
}

/* 月間シフト - 左列固定 */
.shift-grid-wrapper {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
}

#shift-grid {
  display: table;
  border-collapse: collapse;
  min-width: 100%;
}

#shift-grid > div {
  display: table-row;
}

#shift-grid > div > div {
  display: table-cell;
  border: 1px solid #ddd;
  padding: 8px;
  vertical-align: top;
  background: white;
}

/* 最初の列（代理店/地域）を固定 */
#shift-grid > div > div:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #f8f9fa;
  font-weight: 600;
  min-width: 150px;
  max-width: 200px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

/* ヘッダー行（日付）*/
#shift-grid > div:first-child > div {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  text-align: center;
}

/* ヘッダーの最初の列（代理店/地域/場所）*/
#shift-grid > div:first-child > div:first-child {
  z-index: 15;
  background: #3b82f6;
}

/* スマホ表示時の調整 */
@media (max-width: 768px) {
  #shift-grid > div > div:first-child {
    min-width: 120px;
    max-width: 150px;
    font-size: 12px;
    padding: 6px;
  }

  #shift-grid > div > div {
    min-width: 80px;
    font-size: 11px;
    padding: 4px;
  }
}
