/* ================================================
   GRIT — Global Stylesheet (style.css)
   Theme: Dark, minimal, blue-accent with soft glow
   ================================================ */

/* -------- CSS Variables (Theme) -------- */
:root {
  --bg-body: #0b0e13;
  --bg-panel: rgba(0, 0, 0, 0.55);
  --bg-panel-strong: rgba(0, 0, 0, 0.85);

  --text: #f2f5f9;
  --text-dim: #c5cbd6;
  --link: #66b3ff;

  --border: #1b2430;
  --border-soft: #141a24;

  --accent: #0d6efd;
  --accent-600: #0b5ed7;
  --accent-700: #0a58ca;
  --accent-soft: rgba(13, 110, 253, 0.28);
  --accent-glow: 0 0 12px rgba(13, 110, 253, 0.55);

  --good: #28a745;
  --warn: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 6px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.5);

  --padding-sm: 0.5rem;
  --padding-md: 1rem;
  --padding-lg: 2rem;

  --calendar-cell-h: 120px;
}

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

/* -------- Body / Background -------- */
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: url('/images/BG.png') no-repeat center center fixed;
  background-size: cover;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -------- Container / Cards -------- */
.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: var(--padding-lg);
  background: var(--bg-panel);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

.card-wide {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--accent-glow);
  padding: var(--padding-md);
}

/* -------- Flex / Utilities -------- */
.flex-center { display: flex; justify-content: center; align-items: center; }
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; } .mb-1 { margin-bottom: 1rem; } .mb-2 { margin-bottom: 2rem; }

/* -------- Typography -------- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; margin-bottom: 1rem; color: var(--text); }
p, ul, li { color: var(--text); }
small, .muted { color: var(--text-dim); }

/* -------- Links -------- */
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------- Buttons -------- */
button, .btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-700);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s ease, transform 0.05s ease;
}
button:hover, .btn:hover { background: var(--accent-600); }
button:active, .btn:active { transform: translateY(1px); }

.btn-success { background: var(--good); border-color: #1f8e38; }
.btn-success:hover { background: #218838; }

.btn-warning { background: var(--warn); color: #111; border-color: #d6a405; }
.btn-warning:hover { background: #e0a800; }

.btn-danger { background: var(--danger); border-color: #b02a37; }
.btn-danger:hover { background: #c82333; }

.btn-block { display: block; width: 100%; text-align: center; margin-top: 0.5rem; }

/* -------- Badges / Pills -------- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #111a;
  color: var(--text);
  font-size: 0.78rem;
}

/* -------- Alerts -------- */
.alert-success, .alert-warning, .alert-danger, .alert-info {
  padding: var(--padding-md);
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  border: 1px solid var(--border);
}
.alert-success { background: rgba(40,167,69,0.16); color: #c9f7d9; }
.alert-warning { background: rgba(0,0,0,0.18); color: #880808; }
.alert-danger  { background: rgba(220,53,69,0.16); color: #ffd9df; }
.alert-info    { background: rgba(23,162,184,0.18); color: #d5f6fb; }

/* -------- Forms -------- */
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 1rem;
  background: rgba(255,255,255,0.96);
  color: #111;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* -------- Tables (Zebra) -------- */
table { width: 100%; border-collapse: collapse; }
.zebra-table tr:nth-child(even) { background: rgba(255,255,255,0.05); }
.zebra-table th, .zebra-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
}
tr[class^="extra-row-"] td {
  color: inherit; background: inherit; font-size: inherit; opacity: 1 !important; visibility: visible !important;
}

/* -------- Lists (Zebra) -------- */
.zebra-list li:nth-child(even) { background: rgba(255,255,255,0.05); padding: 0.5rem; }

/* -------- Modals -------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000;
}
.modal {
  width: min(500px, 92%);
  padding: var(--padding-lg);
  border-radius: var(--radius-lg);
  background: var(--bg-panel-strong);
  border: 1px solid var(--border);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal .close {
  position: absolute; top: 0.8rem; right: 0.9rem;
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}

/* -------- Calendar (Grid + Spanning Bars) -------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-header {
  text-align: center;
  font-weight: 700;
  padding: 8px 6px;
  background: #0f141c;
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

/* Each week spans the full grid width */
.calendar-week {
  grid-column: 1 / -1;  /* <— critical to avoid "sausage dog" */
  position: relative;   /* parent for overlay bars */
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: var(--calendar-cell-h);
  gap: 6px;
}

.calendar-cell {
  position: relative;
  background: #121823;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm), var(--accent-glow);
  overflow: hidden;
  padding: 6px;
}
.calendar-cell.empty {
  background: #0d121a;
  box-shadow: var(--shadow-sm);
  border-style: dashed;
  opacity: 0.7;
}

.day-num {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Bars container across the bottom of each week row */
.week-overlay {
  position: absolute;
  left: 6px; right: 6px; bottom: 6px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(3, 28px); /* up to 3 stacked, taller bars */
  gap: 4px;
  pointer-events: none; /* bars enable their own pointer */
}

/* --- Better event blocks --- */
.event-span {
  pointer-events: auto;
  position: relative;
  height: 28px;                 /* thicker */
  line-height: 28px;
  border-radius: 14px;          /* pill */
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(13,110,253,0.40), rgba(13,110,253,0.20));
  box-shadow: 0 2px 8px rgba(13,110,253,0.28);
  padding: 0 12px;
  font-size: 0.9rem;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: default;
  transition: transform 80ms ease, box-shadow 120ms ease;
}
.event-span:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13,110,253,0.35);
}

/* Start/end shaping inside the week */
.event-span.is-start { border-top-left-radius: 14px; border-bottom-left-radius: 14px; }
.event-span.is-end   { border-top-right-radius: 14px; border-bottom-right-radius: 14px; }

/* If it continues from previous/into next week, flatten that side */
.event-span.cont-left  { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.event-span.cont-right { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }

/* Continuation chevrons */
.event-span.cont-left::before,
.event-span.cont-right::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: translateY(-50%);
  opacity: 0.9;
}
.event-span.cont-left::before { left: -8px;  border-right: 8px solid rgba(255,255,255,0.5); }
.event-span.cont-right::after { right: -8px; border-left: 8px solid rgba(255,255,255,0.5); }

/* Type color accents */
.event-span.type-general {
  background: linear-gradient(180deg, rgba(13,110,253,0.40), rgba(13,110,253,0.22));
  border-color: rgba(13,110,253,0.45);
  box-shadow: 0 2px 8px rgba(13,110,253,0.28);
}
.event-span.type-war {
  background: linear-gradient(180deg, rgba(220,53,69,0.40), rgba(220,53,69,0.22));
  border-color: rgba(220,53,69,0.45);
  box-shadow: 0 2px 8px rgba(220,53,69,0.28);
}
.event-span.type-perk,
.event-span.type-rotation {
  background: linear-gradient(180deg, rgba(255,193,7,0.42), rgba(255,193,7,0.24));
  border-color: rgba(255,193,7,0.45);
  color: #111;
  box-shadow: 0 2px 8px rgba(255,193,7,0.28);
}
.event-span.type-training {
  background: linear-gradient(180deg, rgba(40,167,69,0.38), rgba(40,167,69,0.22));
  border-color: rgba(40,167,69,0.45);
  box-shadow: 0 2px 8px rgba(40,167,69,0.28);
}
.event-span.type-meeting {
  background: linear-gradient(180deg, rgba(23,162,184,0.38), rgba(23,162,184,0.22));
  border-color: rgba(23,162,184,0.45);
  box-shadow: 0 2px 8px rgba(23,162,184,0.28);
}

/* overlay row layers */
.overlay-row-1 { grid-row: 1; }
.overlay-row-2 { grid-row: 2; }
.overlay-row-3 { grid-row: 3; }

/* column start + span helpers (1..7) */
.col-start-1 { grid-column-start: 1; } .col-start-2 { grid-column-start: 2; }
.col-start-3 { grid-column-start: 3; } .col-start-4 { grid-column-start: 4; }
.col-start-5 { grid-column-start: 5; } .col-start-6 { grid-column-start: 6; }
.col-start-7 { grid-column-start: 7; }

.col-span-1 { grid-column-end: span 1; } .col-span-2 { grid-column-end: span 2; }
.col-span-3 { grid-column-end: span 3; } .col-span-4 { grid-column-end: span 4; }
.col-span-5 { grid-column-end: span 5; } .col-span-6 { grid-column-end: span 6; }
.col-span-7 { grid-column-end: span 7; }

/* -------- Calendar Nav -------- */
.calendar-nav { display: flex; gap: 8px; justify-content: center; align-items: center; }

/* -------- Responsive -------- */
@media (max-width: 900px) {
  body {
    background-attachment: scroll;
  }
  .container,
  .card-wide {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: var(--shadow-sm);
  }
}

@media (max-width: 992px) { :root { --calendar-cell-h: 100px; } }
@media (max-width: 768px) {
  :root { --calendar-cell-h: 88px; }
  .container {
    margin: 1rem auto;
    padding: 1rem;
    width: calc(100% - 1rem);
    max-width: none;
  }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }
  .modal { width: 100%; padding: 1.25rem; font-size: 1rem; }
  .modal .btn { font-size: 1rem; padding: 0.7rem 0.9rem; }
  .btn-block { font-size: 1rem; padding: 0.9rem; }
  .alert-info, .alert-warning, .alert-danger, .alert-success { font-size: 0.95rem; }
  input[type="text"] { font-size: 1rem; padding: 0.6rem; }
  input, select, textarea {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
  button, .btn {
    min-height: 42px;
  }
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  th, td {
    white-space: nowrap;
    font-size: 0.9rem;
  }
  .calendar-nav {
    flex-wrap: wrap;
  }
  .calendar-header {
    font-size: 0.76rem;
    padding: 6px 4px;
  }
  .calendar-week {
    gap: 4px;
  }
  .calendar-cell {
    padding: 4px;
  }
  .day-num {
    top: 4px;
    right: 6px;
    font-size: 0.78rem;
  }
  .week-overlay {
    left: 4px;
    right: 4px;
    bottom: 4px;
    gap: 3px;
    grid-template-rows: repeat(3, 22px);
  }
  .war-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .war-info strong {
    font-size: 1rem;
  }
  .btn-view-payouts {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .container {
    width: calc(100% - 0.5rem);
    margin: 0.5rem auto;
    padding: 0.75rem;
  }
  th, td {
    font-size: 0.84rem;
    padding: 0.45rem;
  }
  button, .btn {
    width: 100%;
  }
  .calendar-header {
    font-size: 0.7rem;
    padding: 5px 2px;
  }
  .day-num {
    font-size: 0.7rem;
  }
}

.war-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    padding: 1rem;
    transition: all 0.3s ease;
}
.war-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.war-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.war-info strong {
    display: block;
    font-size: 1.1em;
    margin-bottom: 0.2em;
}
.war-dates, .war-status {
    font-size: 0.9em;
    margin-right: 0.5rem;
    color: #666;
}

.status-upcoming { color: #007bff; }
.status-active { color: #28a745; }
.status-completed { color: #6c757d; }

.payout-details {
    margin-top: 1rem;
    overflow-x: auto;
}

.payout-table {
    width: 100%;
    border-collapse: collapse;
}

.payout-table th, .payout-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #eaeaea;
    text-align: center;
}

.payout-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.no-data {
    text-align: center;
    color: #777;
}

.btn-view-payouts {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-view-payouts:hover {
    background: #0056b3;
}
