/* ==========================================================================
   GME Admin • Shared Styles
   - Brand tokens
   - Layout (header, sidebar, content)
   - Cards / forms / tables
   - Buttons
   - Modals (PATCH: ensure centered)
   ========================================================================== */

:root{
  --gme-green: #285d45;
  --bg-bone: #f4f1ec;
  --text: #1f2530;
  --muted: #667085;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --radius: 12px;
  --radius-sm: 10px;
}

/* Base reset-ish */
*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-bone);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--gme-green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Header
   ========================================================================== */
.header{
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}
.header .brand{
  display: flex; align-items: center; gap: 10px;
}
.logo{ height: 32px; width: auto; display: block; }
.header .utils{ display: flex; align-items: center; gap: 16px; color: var(--muted); }
.header .utils .lang{ cursor: default; }

/* ==========================================================================
   App frame
   ========================================================================== */
.frame{
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
.sidebar{
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nav{
  display: grid;
  gap: 8px;
}
.nav button{
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.nav button.active{
  border-color: var(--gme-green);
  background: #ebf3ef;
  color: var(--gme-green);
  font-weight: 600;
}
.spacer{ flex: 1; }
.logout{
  appearance: none;
  border: 1px solid #ef4444;
  background: #fff5f5;
  color: #b91c1c;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

/* Content */
.content{
  padding: 24px;
}
.content h1{
  margin: 0 0 16px;
  color: var(--gme-green);
  font-weight: 700;
}

/* ==========================================================================
   Cards / Forms
   ========================================================================== */
.card, form{
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

label{ display:block; margin: 10px 0 6px; color: #2b2b2b; }
input, select, textarea{
  width: 100%;
  max-width: 520px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  outline: none;
}
textarea{ min-height: 120px; resize: vertical; }

/* helper text */
.muted{ color: var(--muted); font-size: 12px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
button{
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover{ filter: brightness(0.98); }

.btn-primary{
  background: var(--gme-green);
  color: #fff;
  border-color: var(--gme-green);
}
.btn-primary:hover{ filter: brightness(1.05); }

/* Row action buttons in tables */
.row-actions{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.row-actions button{
  padding: 6px 10px;
}

/* ==========================================================================
   Tables
   ========================================================================== */
table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: fixed; /* keeps column widths sensible */
}
th, td{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-wrap: break-word;
}
thead th{
  background: #fafafa;
  color: #374151;
  font-weight: 600;
}
tr:last-child td{ border-bottom: 0; }

/* status pill (optional, if you switch to pills later) */
.pill{
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}
.pill--ok{ background:#e8f5ef; color: var(--gme-green); border: 1px solid #cfe6da; }
.pill--off{ background:#f8f8f8; color:#6b7280; border: 1px solid #e5e7eb; }

/* ==========================================================================
   Panels
   ========================================================================== */
.panel{ margin-bottom: 20px; }

/* ==========================================================================
   Modals (PATCH: centered)
   - Any modal backdrop with class .show becomes a flexbox,
     centered both horizontally & vertically.
   ========================================================================== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: none;                 /* hidden by default */
  justify-content: center;       /* PATCH: center horizontally */
  align-items: center;           /* PATCH: center vertically */
  z-index: 1000;
}
.modal-backdrop.show{ display: flex; }

.modal{
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
  width: 90%;
  max-width: 720px;              /* roomy for forms */
  padding: 16px;
  border: 1px solid var(--border);
  max-height: 90vh;          /* keep the modal inside the viewport */
  overflow: auto;            /* allow scrolling when content is tall */
}
.modal header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.modal header h3{
  margin: 0;
  color: var(--gme-green);
}
.modal header button{
  border-radius: 8px;
  padding: 6px 8px;
}
.modal-actions{
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal textarea{ max-width: 100%; }
.modal form { overflow: auto; }

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */
@media (max-width: 900px){
  .frame{ grid-template-columns: 1fr; }
  .sidebar{
    position: sticky;
    top: 56px;
    z-index: 40;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav{ grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .logout{ width: 100%; }
}


/* ==========================================================================
   License List Styles
   ========================================================================== */
#ruLicList{
  display: block !important;
  column-count: 1 !important;
  -webkit-column-count: 1 !important;
  grid-template-columns: none !important;
  columns: auto !important;
}
#ruLicList > label{
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 14px 0 !important;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}
#ruLicList > label > input[type="checkbox"]{
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 4px 0 0 0 !important;
  position: static !important;
  float: none !important;
  transform: none !important;
}
#ruLicList > label > .license-text{
  flex: 1 1 auto;
  min-width: 0;
  display: block !important;
  position: static !important;
  float: none !important;
  clear: none !important;
  width: auto !important;
}
#ruLicList .license-name{ font-weight: 700; }
#ruLicList .license-desc{ font-size: .9rem; color: #667085; }

/* ==========================================================================
   Login Page Tweaks
   ========================================================================== */
#loginForm { max-width: 480px; width: 100%; margin: 0 auto; }
.content .center { display: flex; justify-content: center; }
@media (min-width: 900px) { #loginForm { max-width: 50%; } }

/* ==========================================================================
   REPORTS: compact filters & single-row KPI + donuts
   - Filters in two columns (collapse on narrow screens)
   - One row of 4 cards (2 metrics + 2 donuts)
   - A few tiny utility classes + donut sizing
   ========================================================================== */

/* utilities used in the report row */
.flex{ display:flex; }
.items-center{ align-items:center; }
.gap-4{ gap:16px; }
.metric{ font-size:28px; font-weight:700; line-height:1.2; }

/* two-column filter grid inside the reports panel */
#panel-reports .filters-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
#panel-reports .filters-grid .filters-actions{
  grid-column: 1 / -1;          /* buttons span full width */
  display: flex;
  gap: 10px;
}

/* cards grid helpers */
.cards{ display:grid; gap:16px; margin:12px 0; }
.cards.two{ grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.cards.four{ grid-template-columns: repeat(4, minmax(220px, 1fr)); }

/* donut SVGs rendered by JS: keep a compact, consistent size */
#panel-reports [id^="repDonut"] svg{
  width: 90px;
  height: 90px;
  display: block;
}

/* responsiveness: stack gracefully */
@media (max-width: 1200px){
  .cards.four{ grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 640px){
  #panel-reports .filters-grid{ grid-template-columns: 1fr; }
  .cards.four{ grid-template-columns: 1fr; }
}
