/* ========================================
   案件管理システム - kintone風スタイル
   ======================================== */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
  font-size: 13px;
  color: #333;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: #0061af; text-decoration: none; }
a:hover { text-decoration: underline; color: #004a85; }

/* ========================================
   TOP HEADER BAR
   ======================================== */
.top-header {
  background: #3e3e3e;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
}
.top-header .app-logo {
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.05em;
}
.top-header .header-spacer { flex: 1; }
.top-header .header-user {
  color: #ccc;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.top-header .header-user i { color: #aaa; }

/* ========================================
   LAYOUT
   ======================================== */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 40px);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-app-title {
  padding: 14px 16px 12px;
  font-size: 13px;
  font-weight: bold;
  color: #333;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f8f8;
}

.sidebar-section-label {
  padding: 10px 16px 4px;
  font-size: 11px;
  color: #888;
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a,
.sidebar-nav li button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #444;
  font-size: 13px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}
.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
  background: #f0f5ff;
  text-decoration: none;
  color: #0061af;
}
.sidebar-nav li.active a,
.sidebar-nav li.active button {
  background: #e8f0fe;
  color: #0061af;
  font-weight: bold;
  border-left: 3px solid #0061af;
  padding-left: 13px;
}
.sidebar-nav li a i,
.sidebar-nav li button i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: #888;
}
.sidebar-nav li.active a i,
.sidebar-nav li.active button i { color: #0061af; }

.sidebar-divider {
  height: 1px;
  background: #e8e8e8;
  margin: 8px 12px;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Page Header */
.page-header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  flex-shrink: 0;
}
.page-header h1 {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Page Body */
.page-body {
  padding: 20px 24px;
  flex: 1;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: #0061af;
  color: #fff;
  border-color: #0061af;
}
.btn-primary:hover { background: #004a85; border-color: #004a85; }
.btn-secondary {
  background: #fff;
  color: #333;
  border-color: #bbb;
}
.btn-secondary:hover { background: #f0f0f0; }
.btn-danger {
  background: #e53935;
  color: #fff;
  border-color: #e53935;
}
.btn-danger:hover { background: #c62828; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  padding: 5px 8px;
  background: none;
  border-color: #ddd;
  color: #666;
}
.btn-icon:hover { background: #f5f5f5; }

/* ========================================
   SEARCH BAR
   ======================================== */
.search-bar {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 4px 10px;
  gap: 6px;
  min-width: 240px;
}
.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  color: #333;
  flex: 1;
}
.search-bar input::placeholder { color: #aaa; }
.search-bar i { color: #888; font-size: 12px; }

/* ========================================
   FILTER BAR
   ======================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
  flex-wrap: wrap;
}
.filter-select {
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 5px 24px 5px 10px;
  font-size: 12px;
  font-family: inherit;
  color: #444;
  cursor: pointer;
  min-width: 110px;
}
.filter-select:focus { outline: none; border-color: #0061af; }

/* ========================================
   SUMMARY CARDS
   ======================================== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.summary-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 14px 18px;
}
.summary-card .card-label {
  font-size: 12px;
  color: #777;
  margin-bottom: 6px;
}
.summary-card .card-value {
  font-size: 22px;
  font-weight: bold;
  color: #222;
  line-height: 1.2;
}
.summary-card .card-sub {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}
.summary-card .card-sub.positive { color: #2e7d32; }
.summary-card .card-sub.negative { color: #c62828; }
.summary-card .card-sub.warning  { color: #e65100; }

/* ========================================
   DATA TABLE
   ======================================== */
.table-container {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}
.table-toolbar-left { display: flex; align-items: center; gap: 8px; }
.table-toolbar-right { display: flex; align-items: center; gap: 6px; }
.table-count {
  font-size: 12px;
  color: #777;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: #f5f6f7;
  border-bottom: 2px solid #e0e0e0;
  padding: 8px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: bold;
  color: #555;
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  color: #333;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f5f8ff; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Sort icon */
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #e8e8e8; }
.sort-icon { margin-left: 4px; color: #aaa; font-size: 10px; }
.sort-icon.active { color: #0061af; }

/* ========================================
   STATUS BADGES
   ======================================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}
/* 案件ステータス */
.badge-waiting-payment { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.badge-paid            { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.badge-waiting-product { background: #fce4ec; color: #880e4f; border: 1px solid #f48fb1; }
.badge-received        { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.badge-overdue         { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }
.badge-cancelled       { background: #f5f5f5; color: #616161; border: 1px solid #bdbdbd; }
/* 顧客ステータス */
.badge-active          { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.badge-new             { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.badge-caution         { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.badge-inactive        { background: #f5f5f5; color: #616161; border: 1px solid #bdbdbd; }

/* ========================================
   MONTH TAGS
   ======================================== */
.month-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #c5d8f8;
  white-space: nowrap;
}

/* ========================================
   CATEGORY TAGS
   ======================================== */
.cat-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}
.cat-cosmetics  { background: #fce4ec; color: #880e4f; border: 1px solid #f48fb1; }
.cat-skincare   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.cat-food       { background: #fff8e1; color: #f57f17; border: 1px solid #ffcc02; }
.cat-supplement { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }

/* ========================================
   LINK STYLE (table cell)
   ======================================== */
.cell-link { color: #0061af; cursor: pointer; }
.cell-link:hover { text-decoration: underline; }

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  width: 680px;
  max-width: 96vw;
  margin-bottom: 40px;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 15px; font-weight: bold; color: #333; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #888;
  padding: 2px 6px;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fafafa;
  border-radius: 0 0 4px 4px;
}

/* Form Elements */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.span-2 { grid-column: span 2; }
.form-label {
  font-size: 12px;
  font-weight: bold;
  color: #555;
}
.form-label .required { color: #e53935; margin-left: 2px; }
.form-input,
.form-select,
.form-textarea {
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #333;
  background: #fff;
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #0061af;
  box-shadow: 0 0 0 2px rgba(0,97,175,0.15);
}
.form-textarea { resize: vertical; min-height: 60px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }

/* ========================================
   DETAIL PANEL (slide-in right)
   ======================================== */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 900;
  display: none;
}
.detail-overlay.active { display: block; }

.detail-panel {
  position: fixed;
  top: 40px;
  right: 0;
  bottom: 0;
  width: 520px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
}
.detail-panel.active { transform: translateX(0); }

.detail-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}
.detail-header h2 { font-size: 14px; font-weight: bold; color: #333; }
.detail-header .detail-actions { display: flex; gap: 6px; }

.detail-body { flex: 1; overflow-y: auto; padding: 18px; }
.detail-section-title {
  font-size: 12px;
  font-weight: bold;
  color: #0061af;
  border-bottom: 2px solid #0061af;
  padding-bottom: 4px;
  margin: 14px 0 10px;
}
.detail-grid { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; }
.detail-label { font-size: 12px; color: #888; align-self: center; }
.detail-value { font-size: 13px; color: #333; }

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border-top: 1px solid #f0f0f0;
}
.page-btn {
  padding: 4px 10px;
  border: 1px solid #ddd;
  background: #fff;
  color: #444;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.1s;
}
.page-btn:hover { background: #f0f0f0; }
.page-btn.active { background: #0061af; color: #fff; border-color: #0061af; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 13px; }

/* ========================================
   TOAST / NOTIFICATION
   ======================================== */
.toast-container {
  position: fixed;
  top: 56px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #323232;
  color: #fff;
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { background: #2e7d32; }
.toast.error   { background: #c62828; }
.toast.warning { background: #e65100; }

/* ========================================
   DASHBOARD SPECIFIC
   ======================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.dashboard-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0;
  overflow: hidden;
}
.dashboard-card-header {
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  font-weight: bold;
  color: #444;
  background: #fafafa;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dashboard-card-body {
  padding: 16px;
}
.chart-wrapper { position: relative; height: 200px; }

/* ========================================
   PAYMENT (入金管理) SPECIFIC
   ======================================== */
.payment-status-bar {
  display: flex;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
  height: 8px;
  margin-top: 6px;
}
.payment-status-bar .bar-paid    { background: #4caf50; }
.payment-status-bar .bar-waiting { background: #ff9800; }
.payment-status-bar .bar-overdue { background: #f44336; }

/* ========================================
   UTILITY
   ======================================== */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: #888; }
.text-small  { font-size: 11px; }
.font-bold   { font-weight: bold; }
.nowrap      { white-space: nowrap; }
.hidden      { display: none !important; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f5f5f5; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .sidebar { width: 160px; min-width: 160px; }
  .detail-panel { width: 100%; }
}
@media (max-width: 640px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .sidebar { width: 44px; min-width: 44px; }
  .sidebar-nav li a span,
  .sidebar-nav li button span,
  .sidebar-section-label,
  .sidebar-app-title { display: none; }
}
