/* style.css - Clean Premium Styling for NIPS Member Portal */

:root {
  /* Colors - Light Theme */
  --bg-app: #f4f6f8;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #f8fafc;
  --bg-hover: #f1f5f9;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --primary: #0ea5e9; /* Light sky blue */
  --primary-hover: #0284c7;
  --primary-rgb: 14, 165, 233;
  
  --success: #10b981; /* Emerald */
  --success-hover: #059669;
  --danger: #ef4444; /* Rose */
  --danger-hover: #dc2626;
  --warning: #f59e0b; /* Amber */
  --warning-hover: #d97706;
  
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);
  
  /* Shift Colors */
  --color-shift-early: #e0f2fe; /* Sky blue */
  --text-shift-early: #0369a1;
  --color-shift-middle: #fef3c7; /* Amber */
  --text-shift-middle: #b45309;
  --color-shift-late: #fae8ff; /* Purple */
  --text-shift-late: #a21caf;
  --color-shift-off: #f1f5f9; /* Slate gray */
  --text-shift-off: #475569;
}

body.dark-theme {
  /* Colors - Dark Theme */
  --bg-app: #0f172a; /* Slate 900 */
  --bg-card: #1e293b; /* Slate 800 */
  --bg-sidebar: #1e293b;
  --bg-input: #0f172a;
  --bg-hover: #334155; /* Slate 700 */
  
  --text-main: #f1f5f9; /* Slate 100 */
  --text-muted: #94a3b8; /* Slate 400 */
  
  --primary: #38bdf8; /* Brighter sky blue for dark mode */
  --primary-hover: #0ea5e9;
  --primary-rgb: 56, 189, 248;
  
  --border: #334155;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);

  /* Shift Colors - Dark Theme adjustments for contrast */
  --color-shift-early: #0c4a6e;
  --text-shift-early: #e0f2fe;
  --color-shift-middle: #78350f;
  --text-shift-middle: #fef3c7;
  --color-shift-late: #701a75;
  --text-shift-late: #fae8ff;
  --color-shift-off: #334155;
  --text-shift-off: #cbd5e1;
}

/* ======================================================== */
/* BASE STYLES */
/* ======================================================== */

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

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow: hidden;
  height: var(--viewport-height, 100vh);
  width: 100vw;
}

h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--text-main);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--primary-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Utility classes */
.hide { display: none !important; }
.text-center { text-align: center; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.ml-2 { margin-left: 0.5rem; }

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.shake {
  animation: shake 0.2s ease-in-out 2;
}

/* Common UI Elements */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 8px;
}

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

.btn-success {
  background-color: var(--success);
  color: var(--text-white);
}
.btn-success:hover {
  background-color: var(--success-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: var(--text-white);
}
.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-hover);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  transition: all 0.2s;
}
.btn-icon:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.btn-circle-danger {
  background: var(--danger);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: background-color 0.2s;
}
.btn-circle-danger:hover {
  background: var(--danger-hover);
}

/* Inputs & Forms */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-row {
  display: flex;
  gap: 1rem;
}
.form-row .col {
  flex: 1;
}

/* Messages */
.error-msg {
  background-color: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.success-msg {
  background-color: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--success);
  color: var(--success);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* ======================================================== */
/* 1. LOGIN STYLES */
/* ======================================================== */

#login-container {
  align-items: stretch;
  justify-content: stretch;
  background: var(--bg-app);
}

.login-split-layout {
  display: flex;
  width: 100vw;
  height: var(--viewport-height, 100vh);
}

.login-bg-image {
  flex: 1.2;
  background: url('images/fcoop_rainbow.jpg') center/cover no-repeat;
  position: relative;
}

.login-bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.1) 100%);
}

.login-form-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 2rem;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo {
  font-size: 2.5rem;
  color: var(--primary);
  width: 64px;
  height: 64px;
  background-color: rgba(var(--primary-rgb), 0.1);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.025em;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.password-input-wrapper {
  position: relative;
}
.password-input-wrapper input {
  padding-right: 2.5rem;
}
.password-input-wrapper .btn-icon {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
}

.login-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* モバイル表示用のレスポンシブ調整 */
@media (max-width: 900px) {
  .login-split-layout {
    flex-direction: column;
    overflow-y: auto;
  }
  
  .login-bg-image {
    min-height: 220px;
    flex: none;
  }
  
  .login-form-area {
    flex: 1;
    padding: 1.5rem;
    align-items: flex-start;
  }
  
  .login-card {
    padding: 2rem 1.25rem;
    box-shadow: none;
    border: none;
    background: transparent;
  }
}

/* ======================================================== */
/* 2. APP CONTAINER & LAYOUT */
/* ======================================================== */

#app-container {
  flex-direction: column;
  height: var(--viewport-height, 100vh);
  width: 100vw;
}

/* Header */
.app-header {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  color: var(--primary);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
}

.logo-text {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.05em;
}

.logo-subtitle {
  font-size: 0.75rem;
  background-color: var(--bg-hover);
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
  margin-left: 0.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-hover);
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.user-badge i {
  color: var(--primary);
  font-size: 1.125rem;
}

/* Layout Content */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.app-sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
}

.nav-item i {
  font-size: 1.25rem;
}

.sidebar-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background-color: var(--bg-app);
  position: relative;
}

/* Panel Header */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.title-group h2 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.025em;
}

.title-group p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-only-flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-nav {
  display: none;
}

/* ======================================================== */
/* TAB: PANEL STATE */
/* ======================================================== */

.page-container {
  display: none;
  height: var(--viewport-height, 100vh);
  width: 100vw;
}

.page-container.active {
  display: flex;
}

#app-container.page-container.active {
  display: flex;
}

.tab-panel {
  display: none;
  flex-direction: column;
  min-height: 100%;
}

.tab-panel.active {
  display: flex;
}

/* ======================================================== */
/* SCHEDULE: CALENDAR & MATRIX EDIT */
/* ======================================================== */

.month-selector-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
}

.month-input {
  border: none !important;
  background: none !important;
  font-weight: 600;
  padding: 0.375rem 0.5rem !important;
  width: 140px;
  text-align: center;
  outline: none;
  cursor: pointer;
}

.shift-legend-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.825rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.early { background: var(--text-shift-early); }
.legend-dot.middle { background: var(--text-shift-middle); }
.legend-dot.late { background: var(--text-shift-late); }
.legend-dot.off { background: var(--text-shift-off); }

/* Toggle Switch Styling */
.my-shift-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .3s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Calendar Grid View */
#calendar-grid-wrapper {
  width: 100%;
}

.calendar-header-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.calendar-header-grid div:first-child { color: var(--danger); }
.calendar-header-grid div:last-child { color: var(--primary); }

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  overflow: hidden;
  margin-top: 1px;
}

.calendar-cell {
  background-color: var(--bg-card);
  min-height: 125px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
}

.calendar-cell .day-num {
  font-weight: 600;
  font-size: 0.85rem;
  align-self: flex-start;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.calendar-cell.other-month {
  opacity: 0.4;
}

.calendar-cell.today .day-num {
  background-color: var(--primary);
  color: var(--text-white);
}

.calendar-cell.sunday .day-num { color: var(--danger); }
.calendar-cell.saturday .day-num { color: var(--primary); }
.calendar-cell.today.sunday .day-num,
.calendar-cell.today.saturday .day-num {
  color: var(--text-white);
}

.shift-badges-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 98px;
}

.shift-badge {
  font-size: 0.675rem;
  font-weight: 500;
  padding: 1px 3px;
  border-radius: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 1.15;
}

.shift-badge.early { background-color: var(--color-shift-early); color: var(--text-shift-early); }
.shift-badge.middle { background-color: var(--color-shift-middle); color: var(--text-shift-middle); }
.shift-badge.late { background-color: var(--color-shift-late); color: var(--text-shift-late); }
.shift-badge.off { background-color: var(--color-shift-off); color: var(--text-shift-off); }

.shift-badge .member-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-badge .shift-name {
  font-weight: 700;
}

/* Admin Edit Matrix */
.edit-instructions {
  background-color: rgba(var(--primary-rgb), 0.06);
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.shift-matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.875rem;
  background-color: var(--bg-card);
}

.shift-matrix-table th, 
.shift-matrix-table td {
  border: 1px solid var(--border);
  padding: 0.75rem 0.5rem;
  min-width: 48px;
}

.shift-matrix-table th {
  background-color: var(--bg-hover);
  font-weight: 600;
  color: var(--text-muted);
}

.shift-matrix-table th:first-child {
  position: sticky;
  left: 0;
  background-color: var(--bg-hover);
  z-index: 2;
  min-width: 120px;
}

.shift-matrix-table td:first-child {
  position: sticky;
  left: 0;
  background-color: var(--bg-card);
  z-index: 2;
  font-weight: 600;
  text-align: left;
  padding-left: 1rem;
  box-shadow: 2px 0 5px rgba(0,0,0,0.02);
}

.shift-edit-cell {
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  transition: background-color 0.15s;
}

.shift-edit-cell:hover {
  background-color: var(--bg-hover);
}

.shift-edit-cell.cell-early { background-color: var(--color-shift-early); color: var(--text-shift-early); }
.shift-edit-cell.cell-middle { background-color: var(--color-shift-middle); color: var(--text-shift-middle); }
.shift-edit-cell.cell-late { background-color: var(--color-shift-late); color: var(--text-shift-late); }
.shift-edit-cell.cell-off { background-color: var(--color-shift-off); color: var(--text-shift-off); }

/* ======================================================== */
/* BBS (BULLETIN BOARD) */
/* ======================================================== */

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.filter-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
}

.bbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.bbs-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.bbs-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.bbs-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.bbs-badge.category-お知らせ { background-color: rgba(14, 165, 233, 0.1); color: var(--primary); }
.bbs-badge.category-重要 { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }
.bbs-badge.category-募集 { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.bbs-badge.category-その他 { background-color: rgba(100, 116, 139, 0.1); color: var(--text-muted); }

.bbs-author {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bbs-author span {
  font-weight: 600;
  color: var(--text-main);
}

.bbs-card h3 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.bbs-content {
  font-size: 0.925rem;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  margin-bottom: 1rem;
}

.bbs-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1.125rem;
}

/* ======================================================== */
/* CHAT STYLES */
/* ======================================================== */

.chat-window-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px); /* Fill space */
  padding: 0 !important;
  overflow: hidden;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Date separator in chat */
.chat-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem 0;
  position: relative;
}

.chat-date-separator::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background-color: var(--border);
  z-index: 1;
}

.chat-date-text {
  background-color: var(--bg-card);
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: 99px;
  z-index: 2;
  border: 1px solid var(--border);
}

.chat-bubble-wrapper {
  display: flex;
  gap: 0.75rem;
  max-width: 75%;
}

.chat-bubble-wrapper.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-bubble-wrapper.other {
  align-self: flex-start;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.chat-bubble-wrapper.me .chat-avatar {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  border-color: var(--border);
}

.chat-bubble-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.chat-sender-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.chat-bubble-wrapper.me .chat-sender-name {
  text-align: right;
}

.chat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.95rem;
  word-break: break-all;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.chat-bubble-wrapper.me .chat-bubble {
  background-color: var(--primary);
  color: var(--text-white);
  border-top-right-radius: 4px;
}

.chat-bubble-wrapper.other .chat-bubble {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border-top-left-radius: 4px;
}

.chat-bubble-image {
  margin-top: 0.25rem;
  max-width: 260px;
  max-height: 180px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: block;
  transition: opacity 0.2s;
}
.chat-bubble-image:hover {
  opacity: 0.9;
}
.chat-bubble-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  align-self: flex-end;
  margin-bottom: 2px;
  white-space: nowrap;
}

.chat-bubble-wrapper.me .chat-time {
  margin-right: 0.5rem;
}
.chat-bubble-wrapper.other .chat-time {
  margin-left: 0.5rem;
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
}

.chat-attach-btn {
  font-size: 1.25rem;
}

.chat-input-bar textarea {
  flex: 1;
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 38px;
  line-height: 1.4;
}

.chat-input-bar textarea:focus {
  border-color: var(--primary);
}

.btn-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0 !important;
  flex-shrink: 0;
}

/* Chat Upload Preview Bar */
.upload-preview-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  background-color: var(--bg-hover);
  border-top: 1px solid var(--border);
}

.preview-img-wrapper {
  position: relative;
  width: 60px;
  height: 60px;
}
.preview-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.preview-img-wrapper .btn-circle-danger {
  position: absolute;
  top: -8px;
  right: -8px;
  box-shadow: var(--shadow);
}

.preview-filename {
  font-size: 0.825rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ======================================================== */
/* SETTINGS & MEMBERS */
/* ======================================================== */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.settings-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.settings-card .section-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.add-member-form-card {
  background-color: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.add-member-form-card h4 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.members-table th,
.members-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.members-table th {
  color: var(--text-muted);
  font-weight: 600;
  background-color: var(--bg-hover);
}

.members-table td {
  color: var(--text-main);
}

.members-table .role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}
.members-table .role-badge.admin { background-color: rgba(245, 158, 11, 0.15); color: var(--warning-hover); }
.members-table .role-badge.member { background-color: rgba(100, 116, 139, 0.1); color: var(--text-muted); }

/* ======================================================== */
/* MODALS */
/* ======================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-box {
  width: 100%;
  max-width: 500px;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-sm {
  max-width: 400px;
}

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

.btn-modal-close {
  width: 32px;
  height: 32px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Shift Detail Modal Styles */
.shift-detail-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 350px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.shift-detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-app);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.shift-detail-item.my-detail-shift {
  border-color: var(--primary);
  background-color: rgba(var(--primary-rgb), 0.05);
}

.shift-detail-member {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}

.shift-detail-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.shift-detail-item.my-detail-shift .shift-detail-member-avatar {
  background-color: var(--primary);
  color: white;
}

.shift-detail-type {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

.shift-detail-type.type-early { background-color: var(--color-shift-early); color: var(--text-shift-early); }
.shift-detail-type.type-middle { background-color: var(--color-shift-middle); color: var(--text-shift-middle); }
.shift-detail-type.type-late { background-color: var(--color-shift-late); color: var(--text-shift-late); }
.shift-detail-type.type-off { background-color: var(--color-shift-off); color: var(--text-shift-off); }

/* Lightbox Modal */
.lightbox-overlay {
  background-color: rgba(15, 23, 42, 0.9);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 80vh;
}

.lightbox-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
}

.lightbox-close-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-white);
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.lightbox-close-btn:hover {
  opacity: 1;
}

/* ======================================================== */
/* RESPONSIVE LAYOUTS (MOBILE-FIRST BREAKPOINTS) */
/* ======================================================== */

@media (max-width: 768px) {
  .app-sidebar {
    display: none; /* Hide Sidebar on mobile */
  }

  .app-content {
    padding: 1.25rem;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 16px)); /* Safe padding for bottom nav */
    overflow-x: hidden;
  }

  .app-header {
    padding: 0 1rem;
  }
  
  .header-right .logout-text,
  .header-right .user-badge {
    display: none; /* Simplify header items on small screens */
  }
  
  .header-right {
    gap: 0.25rem;
  }

  /* Mobile Bottom Navigation */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .mobile-nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    height: 100%;
    transition: color 0.2s;
  }

  .mobile-nav-item i {
    font-size: 1.25rem;
  }

  .mobile-nav-item.active {
    color: var(--primary);
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .panel-header .action-group {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Adjust calendar font sizes */
  .calendar-header-grid {
    font-size: 0.75rem;
  }
  
  .calendar-cell {
    min-height: 65px;
    padding: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .calendar-cell:active {
    background-color: var(--bg-hover);
  }
  
  .calendar-cell .day-num {
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
  }

  .shift-badges-container {
    display: flex;
    flex-direction: column !important;
    gap: 2px;
    overflow-y: hidden !important;
    max-height: none !important;
  }

  .shift-badge {
    /* モバイルでもテキストバッジとして表示 */
    display: inline-flex;
    align-items: center;
    width: auto;
    height: auto;
    border-radius: 4px;
    padding: 1px 3px !important;
    font-size: 0.6rem !important;
    line-height: 1.2;
    text-indent: 0;
    overflow: visible;
  }

  .shift-badge.my-shift {
    border: 1px solid var(--primary) !important;
    font-weight: bold;
  }

  .shift-badge .member-name {
    max-width: none;
  }
  
  .calendar-cell:has(.shift-badge.my-shift) {
    background-color: rgba(var(--primary-rgb), 0.05);
  }

  .shift-legend-bar {
    gap: 0.5rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  .chat-window-card {
    height: calc(100vh - 195px);
  }
  
  .chat-bubble-wrapper {
    max-width: 88%;
  }

  .chat-bubble-image {
    max-width: 180px;
    max-height: 140px;
  }
}

/* ======================================================== */
/* NEW CHAT (DM LAYOUT) STYLES */
/* ======================================================== */

.chat-app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 16px;
}

/* When Chat Tab is active, prevent the main content from scrolling and let chat take full space */
body:has(#tab-chat.active) .app-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body:has(#tab-chat.active) #tab-chat.tab-panel.active {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.chat-sidebar {
  width: 260px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background-color: rgba(var(--primary-rgb), 0.01);
  flex-shrink: 0;
}

.chat-sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.chat-member-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.chat-member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
  user-select: none;
}

.chat-member-item:hover {
  background-color: var(--bg-hover);
}

.chat-member-item.active {
  background-color: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
  font-weight: 600;
}

.chat-member-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.chat-member-item.active .chat-member-avatar {
  background-color: var(--primary);
  color: white;
}

.chat-member-info {
  flex: 1;
  min-width: 0;
}

.chat-member-name {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-member-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-main-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  position: relative;
}

.chat-window-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-card);
}

.chat-welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.chat-welcome-state i {
  font-size: 4rem;
  color: rgba(var(--primary-rgb), 0.15);
  margin-bottom: 1rem;
}

/* BBS Post Image attachment style */
.bbs-card-image-container {
  margin-top: 1rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 300px;
  background-color: var(--bg-app);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bbs-card-image-container:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bbs-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.form-control-file {
  width: 100%;
  padding: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background-color: var(--bg-app);
}

/* chat input disabled state */
.chat-input-bar.disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Responsive adjustments for new Chat DM layout */
@media (max-width: 768px) {
  .chat-app-layout {
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  /* Edge-to-edge container on mobile chat to maximize text area */
  body:has(#tab-chat.active) .app-content {
    padding: 0 !important;
  }

  /* When keyboard is NOT focused, reserve space at the bottom for the fixed navigation menu */
  body:not(:has(input:focus, textarea:focus)):has(#tab-chat.active) .chat-app-layout {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* When keyboard is focused, hide mobile nav and let the input bar sit directly at the bottom */
  body:has(input:focus, textarea:focus) .mobile-nav {
    display: none !important;
  }

  body:has(input:focus, textarea:focus):has(#tab-chat.active) .chat-app-layout {
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }

  .chat-sidebar {
    width: 100%;
    height: 90px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .chat-sidebar-header {
    display: none;
  }

  .chat-member-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem;
    gap: 0.5rem;
    white-space: nowrap;
  }

  .chat-member-item {
    flex-direction: column;
    padding: 0.35rem 0.5rem;
    gap: 0.25rem;
    align-items: center;
    border-radius: 10px;
    min-width: 65px;
    margin-bottom: 0;
  }

  .chat-member-info {
    text-align: center;
    width: 100%;
  }

  .chat-member-name {
    font-size: 0.75rem;
    width: 60px;
  }

  .chat-member-role {
    display: none;
  }

  .chat-member-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .chat-main-window {
    flex: 1;
    min-height: 0;
    height: calc(100% - 90px);
  }
}

/* My active user shift badge highlight */
.shift-badge.my-shift {
  border: 2px solid var(--primary) !important;
  font-weight: 700;
  box-shadow: 0 0 6px rgba(var(--primary-rgb), 0.4);
}

/* Chat bubble hover actions (edit/delete) */
.chat-bubble-wrapper.me {
  position: relative;
}

.chat-bubble-actions {
  display: none;
  position: absolute;
  top: 50%;
  left: -65px;
  transform: translateY(-50%);
  gap: 0.35rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.2rem 0.4rem;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.chat-bubble-wrapper.me:hover .chat-bubble-actions {
  display: flex;
}

.chat-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.chat-action-btn:hover {
  background-color: var(--bg-hover);
}

.chat-action-btn.delete:hover {
  color: var(--danger);
  background-color: rgba(var(--danger-rgb), 0.1);
}

.chat-action-btn.edit:hover {
  color: var(--primary);
  background-color: rgba(var(--primary-rgb), 0.1);
}

/* Unread message badge */
.chat-member-item {
  position: relative;
}

.chat-member-item.has-unread-msg {
  background-color: rgba(var(--primary-rgb), 0.05) !important;
  border-left: 3.5px solid var(--danger) !important;
}

.chat-member-item .unread-dot {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--danger);
  font-size: 0.65rem;
}

/* Nav Item Unread Badge */
.nav-item {
  position: relative;
}

.nav-unread-dot {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--danger);
  font-size: 0.75rem;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% {
    transform: translateY(-50%) scale(0.9);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-50%) scale(1.25);
    opacity: 1;
  }
  100% {
    transform: translateY(-50%) scale(0.9);
    opacity: 0.7;
  }
}
