/*
 * IndexGram — Calendar Plugin Styles
 * Uses CSS custom properties from the active theme.
 */

/* ── Container ─────────────────────────────────────────────────────────────── */
.ig-calendar {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-color, #000);
  border: 2px solid;
  border-color: var(--border-light, #E0D8EC) var(--border-dark, #3A2050) var(--border-dark, #3A2050) var(--border-light, #E0D8EC);
  background: var(--content-bg, #FFF);
  margin: 12px 0;
}

.ig-cal-error {
  padding: 10px 14px;
  background: var(--flash-error-bg, #FFD0D0);
  border: 1px solid #CC0000;
  color: #800000;
  font-size: 13px;
  margin: 8px 0;
}

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.ig-cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--titlebar-bg, #5B2D8E);
  background: linear-gradient(90deg, var(--titlebar-bg, #5B2D8E) 0%, var(--titlebar-bg-end, #2D1B6B) 100%);
  padding: 4px 8px;
}

.ig-cal-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ig-cal-title {
  color: var(--titlebar-text, #FFF);
  font-weight: bold;
  font-size: 13px;
  min-width: 140px;
  text-align: center;
  padding: 0 6px;
}

.ig-cal-btn {
  background: rgba(255,255,255,0.15);
  color: var(--titlebar-text, #FFF);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.4;
  transition: background 0.1s;
}
.ig-cal-btn:hover {
  background: rgba(255,255,255,0.3);
}
.ig-cal-btn:active {
  background: rgba(0,0,0,0.2);
}

/* ── View switcher ─────────────────────────────────────────────────────────── */
.ig-cal-views {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.ig-cal-view-btn {
  background: rgba(255,255,255,0.12);
  color: var(--titlebar-text, #FFF);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 2px 9px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  line-height: 1.5;
  transition: background 0.1s;
}
.ig-cal-view-btn:hover {
  background: rgba(255,255,255,0.28);
}
.ig-cal-view-btn.active {
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.6);
  font-weight: bold;
}

/* ── Body ──────────────────────────────────────────────────────────────────── */
.ig-cal-body {
  padding: 0;
  overflow-x: auto;
}

.ig-cal-empty-msg {
  padding: 20px;
  text-align: center;
  color: #888;
  font-style: italic;
}

/* ── Monthly Grid ──────────────────────────────────────────────────────────── */
.ig-cal-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ig-cal-grid thead th {
  background: var(--titlebar-bg, #5B2D8E);
  color: var(--titlebar-text, #FFF);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  padding: 4px 2px;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.ig-cal-grid thead th:last-child { border-right: none; }

.ig-cal-cell {
  vertical-align: top;
  border: 1px solid var(--border-light, #E0D8EC);
  padding: 2px 3px;
  min-height: 68px;
  background: var(--content-bg, #FFF);
}
.ig-cal-cell:hover { background: var(--table-row-alt, #EDE8F5); }

.ig-cal-other-month {
  background: var(--window-bg, #C8C4D0);
  opacity: 0.5;
}

.ig-cal-today-cell {
  background: var(--flash-info-bg, #DDD0F8) !important;
}

.ig-cal-day-num {
  font-size: 11px;
  color: #666;
  text-align: right;
  margin-bottom: 2px;
  font-weight: bold;
}
.ig-cal-today-num {
  display: inline-block;
  background: var(--accent-color, #5B2D8E);
  color: var(--titlebar-text, #FFF);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 10px;
  float: right;
}

/* ── Event bars ────────────────────────────────────────────────────────────── */
.ig-cal-event-bar {
  background: var(--accent-color, #5B2D8E);
  color: var(--titlebar-text, #FFF);
  font-size: 10px;
  padding: 1px 4px;
  margin-bottom: 1px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  border-radius: 1px;
}
.ig-cal-event-bar a {
  color: var(--titlebar-text, #FFF) !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ig-cal-event-bar a:hover {
  color: var(--titlebar-text, #FFF) !important;
  text-decoration: underline;
}

.ig-cal-more {
  font-size: 9px;
  color: var(--link-color, #4A007A);
  text-align: right;
  cursor: pointer;
}

/* ── Weekly Grid ───────────────────────────────────────────────────────────── */
.ig-cal-week-grid {
  min-width: 500px;
}
.ig-cal-week-grid thead th {
  text-align: center;
  padding: 5px 4px;
  font-size: 11px;
}
.ig-cal-week-cell {
  vertical-align: top;
  border: 1px solid var(--border-light, #E0D8EC);
  padding: 4px;
  min-height: 100px;
}
.ig-cal-ev-time {
  font-size: 9px;
  opacity: 0.8;
}
.ig-cal-empty {
  color: #bbb;
  text-align: center;
  font-size: 18px;
  padding-top: 24px;
}

/* ── Agenda View ───────────────────────────────────────────────────────────── */
.ig-cal-agenda {
  padding: 4px 0;
}
.ig-cal-agenda-day {
  display: flex;
  border-bottom: 1px solid var(--border-light, #E0D8EC);
}
.ig-cal-agenda-date {
  min-width: 140px;
  flex-shrink: 0;
  background: var(--window-bg, #C8C4D0);
  padding: 8px 10px;
  font-weight: bold;
  font-size: 11px;
  color: var(--text-color, #000);
  border-right: 2px solid var(--border-mid, #8070A0);
}
.ig-cal-agenda-events {
  flex: 1;
  padding: 4px 0;
}
.ig-cal-agenda-event {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px dashed var(--border-light, #E0D8EC);
}
.ig-cal-agenda-event:last-child { border-bottom: none; }
.ig-cal-agenda-time {
  min-width: 70px;
  flex-shrink: 0;
  font-size: 11px;
  color: #555;
  padding-top: 2px;
}
.ig-cal-agenda-info { flex: 1; }
.ig-cal-agenda-info a {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--link-color, #4A007A) !important;
  text-decoration: underline;
}
.ig-cal-agenda-loc {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}
.ig-cal-agenda-desc {
  font-size: 11px;
  color: #555;
  margin-top: 3px;
  white-space: pre-line;
}

/* ── Year View ─────────────────────────────────────────────────────────────── */
.ig-cal-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  padding: 8px;
}
.ig-cal-mini-month {
  border: 1px solid var(--border-light, #E0D8EC);
}
.ig-cal-mini-title {
  background: var(--titlebar-bg, #5B2D8E);
  color: var(--titlebar-text, #FFF);
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  padding: 3px 0;
}
.ig-cal-mini-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  table-layout: fixed;
}
.ig-cal-mini-grid thead th {
  text-align: center;
  padding: 2px 1px;
  font-size: 9px;
  color: #666;
  background: var(--window-bg, #C8C4D0);
}
.ig-cal-mini-grid td {
  text-align: center;
  padding: 2px 1px;
  cursor: default;
}
.ig-mini-today {
  background: var(--accent-color, #5B2D8E);
  color: var(--titlebar-text, #FFF);
  border-radius: 50%;
  font-weight: bold;
}
.ig-mini-has-events {
  font-weight: bold;
  color: var(--link-color, #4A007A);
  text-decoration: underline;
}
.ig-mini-today.ig-mini-has-events {
  color: var(--titlebar-text, #FFF);
  text-decoration: underline;
}

/* ── List View ─────────────────────────────────────────────────────────────── */
.ig-cal-list {
  overflow-x: auto;
}
.ig-cal-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ig-cal-list-table thead th {
  background: var(--table-header-bg, #5B2D8E);
  color: var(--table-header-text, #FFF);
  padding: 5px 8px;
  text-align: left;
  font-size: 11px;
}
.ig-cal-list-table tbody td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-light, #E0D8EC);
  vertical-align: top;
}
.ig-cal-list-table tbody tr:nth-child(even) td {
  background: var(--table-row-alt, #EDE8F5);
}
.ig-cal-list-table tbody tr:hover td {
  background: var(--flash-info-bg, #DDD0F8);
}
.ig-cal-list-date { white-space: nowrap; font-weight: bold; }
.ig-cal-list-time { white-space: nowrap; color: #555; }
.ig-cal-list-table a {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--link-color, #4A007A) !important;
  text-decoration: underline;
}
.ig-cal-list-desc {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

/* ── Event Popup ───────────────────────────────────────────────────────────── */
.ig-cal-popup {
  position: fixed;
  z-index: 9000;
  background: var(--content-bg, #FFF);
  border: 2px solid;
  border-color: var(--border-light, #E0D8EC) var(--border-dark, #3A2050) var(--border-dark, #3A2050) var(--border-light, #E0D8EC);
  box-shadow: 4px 4px 12px rgba(0,0,0,0.4);
  min-width: 240px;
  max-width: 340px;
  font-size: 12px;
}
.ig-cal-popup-head {
  background: var(--titlebar-bg, #5B2D8E);
  background: linear-gradient(90deg, var(--titlebar-bg, #5B2D8E) 0%, var(--titlebar-bg-end, #2D1B6B) 100%);
  color: var(--titlebar-text, #FFF);
  padding: 4px 8px;
  font-weight: bold;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ig-cal-popup-close {
  background: none;
  border: none;
  color: var(--titlebar-text, #FFF);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.ig-cal-popup-body {
  padding: 8px 10px;
}
.ig-cal-popup-row {
  margin-bottom: 4px;
  font-size: 11px;
}
.ig-cal-popup-label {
  font-weight: bold;
  color: var(--accent-color, #5B2D8E);
  margin-right: 4px;
}
.ig-cal-popup a {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--link-color, #4A007A) !important;
  text-decoration: underline;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ig-cal-toolbar { flex-direction: column; align-items: flex-start; }
  .ig-cal-title   { min-width: 100px; }
  .ig-cal-views   { width: 100%; }
  .ig-cal-view-btn { flex: 1; text-align: center; }

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

  .ig-cal-agenda-day { flex-direction: column; }
  .ig-cal-agenda-date { border-right: none; border-bottom: 1px solid var(--border-mid, #8070A0); }
}

@media (max-width: 400px) {
  .ig-cal-year-grid { grid-template-columns: 1fr; }
}
