/* ===================================
   Tool: date-calculator
   日付・営業日計算ツール
   =================================== */

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  background: var(--bg-card);
  padding: var(--space-sm);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: var(--green-main);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Input Section */
.input-section {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-xl);
  overflow: hidden;
}

.input-section h2 {
  font-size: 1.2rem;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.date-range-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
  min-width: 140px;
}

.date-field label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-accent);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  display: inline-block;
  width: fit-content;
}

.date-field input[type="date"] {
  padding: var(--space-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  background: var(--bg-input);
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

.date-field input[type="date"]:focus {
  outline: none;
  border-color: var(--green-main);
  box-shadow: 0 0 0 3px rgba(76, 175, 145, 0.15);
}

.date-field input[type="date"]:hover {
  border-color: var(--green-light);
}

/* Date Input Wrapper with Icon */
.date-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.date-input-wrapper input[type="date"] {
  padding-left: 2.8rem;
  width: 100%;
}

.date-icon {
  position: absolute;
  left: 0.75rem;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-input-wrapper.compact {
  flex-shrink: 1;
  min-width: 0;
}

.date-input-wrapper.compact input[type="date"] {
  padding: var(--space-sm) var(--space-sm) var(--space-sm) 2.5rem;
  font-size: 0.95rem;
}

.date-input-wrapper.compact .date-icon {
  font-size: 1rem;
  left: 0.6rem;
}

.date-separator {
  font-size: 1.2rem;
  color: var(--text-muted);
  padding-bottom: var(--space-sm);
}

.calc-btn {
  padding: var(--space-sm) var(--space-xl);
  background: var(--green-main);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calc-btn:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.quick-btns {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* Add Section */
.add-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.add-operator {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--green-main);
  padding-bottom: var(--space-sm);
}

.number-field,
.type-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.number-field label,
.type-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.number-field input,
.type-field select {
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: var(--bg-input);
  min-width: 100px;
}

.number-field input:focus,
.type-field select:focus {
  outline: none;
  border-color: var(--green-main);
}

/* Result Section */
.result-section {
  margin-bottom: var(--space-xl);
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.result-card {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-md);
  border: 2px solid transparent;
}

.result-card.highlight {
  border-color: var(--green-main);
  background: linear-gradient(135deg, rgba(76, 175, 145, 0.05) 0%, rgba(90, 175, 163, 0.05) 100%);
}

.result-card.large {
  grid-column: 1 / -1;
  padding: var(--space-2xl);
}

.result-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--green-main);
  line-height: 1.2;
}

.result-card.large .result-value {
  font-size: 3rem;
}

.result-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: var(--space-sm);
}

.result-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Detail Section */
.detail-section {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-lg);
}

.detail-section h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.detail-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.detail-value {
  font-weight: 600;
  color: var(--text-primary);
}

.holiday-list {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-light);
}

.holiday-list-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.holiday-tag {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-accent);
  color: var(--green-dark);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin: var(--space-xs);
}

.copy-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

/* Calendar */
.calendar-container {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-xl);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.calendar-nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.calendar-nav-btn:hover {
  background: var(--bg-hover);
}

.calendar-month {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}

.calendar-actions {
  display: flex;
  gap: var(--space-sm);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-weekday {
  padding: var(--space-sm);
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.calendar-weekday.sun {
  color: var(--error);
}

.calendar-weekday.sat {
  color: var(--info);
}

.calendar-day {
  padding: var(--space-sm);
  min-height: 70px;
  background: var(--bg-card);
  position: relative;
}

.calendar-day.empty {
  background: var(--bg-secondary);
}

.calendar-day.sun {
  background: rgba(239, 68, 68, 0.05);
}

.calendar-day.sat {
  background: rgba(59, 130, 246, 0.05);
}

.calendar-day.sun .day-number {
  color: var(--error);
}

.calendar-day.sat .day-number {
  color: var(--info);
}

.calendar-day.holiday {
  background: rgba(239, 68, 68, 0.1);
}

.calendar-day.holiday.custom {
  background: rgba(168, 85, 247, 0.1);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px var(--green-main);
}

.day-number {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.holiday-name {
  display: block;
  font-size: 0.7rem;
  color: var(--error);
  margin-top: var(--space-xs);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day.custom .holiday-name {
  color: var(--purple);
}

.calendar-legend {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
}

.legend-color.holiday {
  background: rgba(239, 68, 68, 0.3);
}

.legend-color.custom {
  background: rgba(168, 85, 247, 0.3);
}

.legend-color.today {
  box-shadow: inset 0 0 0 2px var(--green-main);
  background: white;
}

/* Custom Holiday */
.custom-holiday-section {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-xl);
  overflow: hidden;
}

.custom-holiday-section h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-sm);
}

.section-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.custom-holiday-form {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.custom-holiday-form input[type="date"],
.custom-holiday-form input[type="text"] {
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  box-sizing: border-box;
  max-width: 100%;
}

.custom-holiday-form input[type="date"] {
  width: auto;
  min-width: 0;
  flex-shrink: 1;
}

.custom-holiday-form input[type="text"] {
  flex: 1;
  min-width: 100px;
}

.custom-holiday-form input:focus {
  outline: none;
  border-color: var(--green-main);
}

.custom-holiday-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.custom-holiday-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: var(--space-md);
}

.custom-holiday-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.custom-holiday-date {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.custom-holiday-name {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Month Summary */
.month-summary {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.month-summary h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.summary-item {
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.summary-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green-main);
}

.summary-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 300px;
  overflow-y: auto;
}

.history-empty {
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-lg);
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-icon {
  font-size: 1.2rem;
}

.history-content {
  flex: 1;
}

.history-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.history-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.history-actions {
  margin-top: var(--space-md);
  text-align: right;
}

/* Usage Grid */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.usage-item {
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.usage-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.usage-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.faq-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: none;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.faq-question::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.faq-item.open .faq-question::after {
  content: '−';
}

.faq-question:hover {
  background: var(--bg-hover);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-item.open .faq-answer {
  max-height: 500px;
}

.faq-answer-inner {
  padding: var(--space-lg);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Section Card */
.section-card {
  background: var(--bg-card);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-xl);
}

.section-card h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--dark-forest);
  color: white;
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .tab-nav {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1 1 calc(50% - var(--space-sm));
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
  }

  .date-range-wrapper,
  .add-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .date-separator,
  .add-operator {
    text-align: center;
    padding: var(--space-xs) 0;
  }

  .calc-btn {
    width: 100%;
  }

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

  .result-value {
    font-size: 2rem;
  }

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

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

  .usage-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 50px;
    padding: var(--space-xs);
  }

  .day-number {
    font-size: 0.9rem;
  }

  .holiday-name {
    font-size: 0.6rem;
  }

  .custom-holiday-form {
    flex-direction: column;
  }

  .custom-holiday-form input[type="date"],
  .custom-holiday-form input[type="text"],
  .custom-holiday-form button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .date-field {
    width: 100%;
  }

  .date-field input[type="date"] {
    font-size: 1rem;
  }

  .date-input-wrapper {
    width: 100%;
  }

  .date-input-wrapper.compact {
    width: 100%;
    flex-shrink: 0;
  }

  .date-input-wrapper.compact input[type="date"] {
    width: 100%;
  }
}

@media (max-width: 500px) {
  .input-section,
  .section-card,
  .calendar-container,
  .custom-holiday-section,
  .month-summary,
  .detail-section {
    padding: var(--space-md);
  }

  .result-card {
    padding: var(--space-md);
  }

  .result-value {
    font-size: 1.5rem;
  }

  .calendar-month {
    font-size: 1.1rem;
    min-width: 100px;
  }

  .calendar-nav-btn {
    width: 32px;
    height: 32px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .quick-btns {
    justify-content: center;
  }

  .quick-btns .btn {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    padding: var(--space-xs) var(--space-sm);
  }
}

/* Button Extras */
.btn-xs {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

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