/* ==============================
   DASHBOARD BASE STYLES
   ============================== */

body.dashboard {
  background: #f9fafb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #333;
  margin: 0;
}

/* --- CONTAINER WRAPPER --- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* --- NAVBAR --- */
.dashboard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #222;
  color: #fff;
  padding: 10px 20px;
  flex-wrap: wrap;
}

.dashboard-nav .left a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.dashboard-nav .right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-nav select {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  background: #fff;
  color: #222;
}

.dashboard-nav span.user-info {
  color: #fff;
  font-size: 0.9rem;
}

.dashboard-nav span.user-info strong {
  color: #fff;
  font-weight: 700;
}

.dashboard-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}

/* --- PUBLISH BANNER --- */
.publish-banner {
  background: #fffbe6;
  color: #444;
  padding: 12px 16px;
  text-align: center;
  border-bottom: 1px solid #f0d972;
  font-size: 0.95rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 2000;
}

.publish-banner .btn.small {
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  background: #0074d9;
  color: #fff;
  border-radius: 4px;
  border: none;
}

.publish-banner .btn.small:hover {
  background: #005fa3;
}

/* ==========================
   UNIVERSAL DASHBOARD MODAL
   ========================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  z-index: 9999;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
  opacity: 0;
  overflow-y: auto; /* ✅ allow scrolling the whole modal if too tall */
  padding: 40px 0;  /* ✅ give breathing space top/bottom */
}

.modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 90%;
  max-width: 900px; /* ✅ wider for multi-column forms */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.25s ease;
  position: relative;
  margin: auto; /* ✅ ensures it stays centered */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  max-height: 90vh; /* ✅ keeps it within screen */
  overflow: hidden; /* ✅ delegate scroll to modal-body */
}

@keyframes modalFadeIn {
  from {
    transform: translateY(25px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 12px;
  margin-bottom: 1.2em;
}

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  color: #222;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.7rem;
  cursor: pointer;
  color: #444;
  line-height: 1;
  transition: color 0.2s ease;
}
.close-btn:hover {
  color: #0074d9;
}

/* ✅ scrollable content area */
.modal-body {
  overflow-y: auto;
  padding-right: 10px;
  max-height: calc(90vh - 120px); /* header + padding space */
}

/* --- form elements inside modal --- */
.modal form label {
  font-weight: 600;
  margin-top: 0.7em;
  display: block;
}

.modal form input,
.modal form select,
.modal form textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.modal form textarea {
  min-height: 80px;
  resize: vertical;
}

/* ✅ auto-adjusting columns for form grids */
.modal .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.modal .grid input,
.modal .grid select,
.modal .grid textarea {
  max-width: 100%;
  box-sizing: border-box;
}

/* ==========================
   MODAL ACTION BUTTONS
   ========================== */
.modal-actions {
  display: flex;
  justify-content: center;   /* ✅ center the buttons */
  align-items: center;
  gap: 16px;                 /* ✅ even spacing between buttons */
  margin-top: 30px;          /* ✅ spacing above the button row */
  padding-top: 15px;
  border-top: 1px solid #eee; /* ✅ subtle separation line */
}

.modal-actions .btn {
  min-width: 120px;           /* ✅ uniform button width */
  text-align: center;
}


@media (max-width: 700px) {
  .modal .grid {
    grid-template-columns: 1fr; /* single column on small screens */
  }
}

/* ==========================
   API LOG MODAL CUSTOM STYLES
   ========================== */
.log-toolbar {
  position: sticky;
  top: 0;
  background: #2b2b2b;
  padding: 10px 12px;
  border-bottom: 1px solid #444;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.log-toolbar input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1e1e1e;
  color: #eee;
  font-family: inherit;
  font-size: 0.9rem;
}

.log-toolbar #logCount {
  font-size: 0.85rem;
  color: #aaa;
}

.log-scroll-area {
  max-height: 65vh;
  overflow-y: auto;
  padding: 10px;
  background: #000;
  border-radius: 6px;
  border: 1px solid #333;
  margin-top: 8px;
}

/* Scroll behavior for console */
.log-scroll-area {
  scroll-behavior: smooth; /* ✅ smooth transitions when auto-scrolling */
}


#rawContent {
  white-space: pre-wrap;
  font-family: "Fira Code", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #ccc;
  margin: 0;
}

.log-footer {
  position: sticky;
  bottom: 0;
  background: #1e1e1e;
  border-top: 1px solid #333;
  padding: 12px 0;
  z-index: 5;
  justify-content: center;
}

.log-footer .btn {
  min-width: 120px;
}


/* ==========================
   DASHBOARD GRID / TILES
   ========================== */
.dashboard-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.tile-card {
  background: #fff;
  border-radius: 10px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tile-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  background: #f8fbff; /* subtle tint on hover */
}

/* --- TILE ICONS --- */
.tile-card .icon {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.04);
  transition: all 0.25s ease;
}

.tile-card .icon img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}

.tile-card:hover .icon {
  background: #e9f2ff; /* gentle tint */
}

.tile-card:hover .icon img {
  transform: scale(1.06);
}

.tile-card h3 {
  margin: 6px 0 4px;
  font-size: 1.05rem;
  color: #222;
}

.tile-card p {
  font-size: 0.9rem;
  color: #666;
  margin: 0;
}

/* --- PAGE HEADERS --- */
.top-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.top-icon img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.top-icon h1 {
  font-size: 1.4rem;
  color: #222;
  margin: 0;
}

/* --- CARDS --- */
.card {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

/* ==========================
   STATUS BADGES
   ========================== */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-transform: capitalize;
}

.status-badge.ok {
  background: #1c9b48;       /* green  */
}

.status-badge.due {
  background: #e9b000;       /* amber  */
  color: #000;
}

.status-badge.expired {
  background: #c62828;       /* red    */
}

.status-badge.inactive {
  background: #6c757d;       /* grey   */
}

.status-badge.active {
  background: #0074d9;       /* blue   */
}


/* --- FEATURES (License Editor) --- */
.features-group {
  margin-top: 1.5em;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1em;
  background: #fafafa;
}
.features-group legend {
  font-weight: 600;
  color: #333;
  padding: 0 6px;
  margin-bottom: 0.5em;
}
.features-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.8em 1em;
}
.feature-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px 12px;
  transition: background 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
.feature-toggle:hover {
  border-color: #007bff;
}
.feature-toggle.active {
  background: #e7f3ff;
  border-color: #007bff;
}
.feature-toggle input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #999;
  border-radius: 4px;
  background: #fff;
  transition: all 0.2s ease;
  flex-shrink: 0;
  cursor: pointer;
}
.feature-toggle input[type="checkbox"]:checked {
  background: #007bff;
  border-color: #007bff;
}
.feature-label {
  color: #333;
  font-size: 0.95rem;
  user-select: none;
  flex-grow: 1;
}

/* --- TABLES --- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

.table th {
  background: #f3f4f6;
  font-weight: 600;
  color: #444;
}

.table tr:hover {
  background: #f9f9f9;
}

/* --- BUTTONS --- */
.btn {
  display: inline-block;
  background: #0074d9;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn:hover {
  background: #005fa3;
}

.btn.small {
  padding: 5px 10px;
  font-size: 0.85rem;
}

/* --- FORMS --- */
input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
}

/* --- EMAIL LIST --- */
.email-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #eee;
  padding: 3px 0;
  font-size: 0.95rem;
}

.email-item strong {
  width: 160px;
  flex-shrink: 0;
  color: #333;
}

.email-item span {
  color: #555;
  overflow-wrap: anywhere;
}

/* ==============================
   📱 RESPONSIVE DASHBOARD
   ============================== */

@media (max-width: 1024px) {
  .dashboard-tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  .tile-card .icon {
    width: 80px;
    height: 80px;
  }

  .tile-card .icon img {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 10px;
  }

  /* --- NAVBAR STACK --- */
  .dashboard-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dashboard-nav .left,
  .dashboard-nav .right {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .dashboard-nav select {
    width: 100%;
  }

  .dashboard-nav span.user-info {
    text-align: left;
    width: 100%;
    margin-top: 5px;
  }

  /* --- DASHBOARD GRID STACK --- */
  .dashboard-tiles {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tile-card .icon {
    width: 60px;
    height: 60px;
  }

  .tile-card .icon img {
    width: 45px;
    height: 45px;
  }

  /* --- PUBLISH BANNER --- */
  .publish-banner {
    flex-direction: column;
    text-align: center;
    gap: 6px;
    font-size: 0.9rem;
    padding: 10px;
  }

  /* --- TABLES --- */
  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.85rem;
  }

  .table th,
  .table td {
    padding: 6px;
  }

  /* --- MODALS --- */
  .modal {
    width: 95%;
    max-width: 500px;
    padding: 16px;
  }

  /* --- EMAIL & FORM ROWS --- */
  .form-row,
  .email-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row label,
  .email-item strong {
    width: auto;
    text-align: left;
    margin-bottom: 4px;
  }

  /* --- BUTTONS --- */
  .btn.big {
    width: 100%;
    padding: 14px;
    font-size: 1em;
    border-radius: 8px;
  }
}
