/* ========= BASE ========= */
:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: #f7f7f9;
  color: #222;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========= TOP BAR ========= */
header.topbar {
  background: #111827;
  color: #ffffff;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-left img,
.topbar-logo {
  width: 90px;
  height: auto;
  object-fit: contain;
  filter: invert(1) brightness(1000%);
}

.topbar-center {
  text-align: center;
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding-right: 1.5rem;
}

/* Shared pill style */
.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.topbar-pill i {
  font-size: 0.9em;
}

.topbar-pill:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.topbar-pill-muted {
  background-color: rgba(15, 23, 42, 0.9);
  border-color: transparent;
  cursor: default;
}

.topbar-pill-muted:hover {
  background-color: rgba(15, 23, 42, 0.9);
  transform: none;
}

.topbar-pill-solid {
  background-color: #f9fafb;
  color: #111827;
  border-color: transparent;
}

.topbar-pill-solid:hover {
  background-color: #e5e7eb;
  transform: translateY(-1px);
}

/* ========= DASHBOARD (INDEX.PHP) ========= */
.main-wrapper {
  max-width: 1100px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem 2rem;
  flex: 1;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
  padding: 2rem 2rem 2.2rem;
}

.card-subtitle {
  margin-top: 0.2rem;
  color: #6b7280;
}

/* Tiles grid */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.tile {
  padding: 1.4rem 1.2rem;
  border-radius: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  border-color: #4b5563;
}

.tile-icon {
  font-size: 48px;
  color: #111827;
  margin-bottom: 0.6rem;
}

.tile-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.tile-desc {
  font-size: 0.85rem;
  color: #6b7280;
}

/* ========= LOGIN VIEW ========= */
.login-page {
  min-height: 100vh;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #f9fafb;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  padding: 2rem 2.2rem 2.3rem;
  text-align: center;
}

.login-logo img {
  height: 46px;
  width: auto;
}

.login-heading {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: #111827;
}

.login-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 1.3rem;
}

.login-form {
  text-align: left;
}

.form-field {
  margin-bottom: 0.9rem;
}

.form-field label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: #374151;
}

.form-field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 1px #111827;
}

.login-form input[type="tel"] {
  background-color: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-size: 0.95rem;
  box-shadow: none;
}

.login-form input[type="tel"]::placeholder {
  color: #9ca3af;
}

.btn-primary {
  width: 100%;
  border: none;
  background: #111827;
  color: #ffffff;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.4rem;
}

.btn-primary:hover {
  background: #0f172a;
}

.form-error {
  margin-top: 0.7rem;
  min-height: 1.1rem;
  font-size: 0.85rem;
  color: #b91c1c;
}

/* ========= REFERENCE PAGES ========= */
.ref-main {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem 2rem;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  flex: 1;
}

/* Hero header with rounded corners */
.ref-header {
  background: #222;
  color: #ffffff;
  padding: 1.5rem 1rem;
  text-align: center;
  margin: -1rem -1rem 1rem;
  border-radius: 10px 10px 0 0;
}

.ref-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  font-weight: 700;
}

.ref-header p {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  opacity: 0.85;
  line-height: 1.5;
}

/* Sticky navigation */
.ref-nav {
  border-bottom: 1px solid #eee;
  padding: 1rem 1.3rem 0.7rem;
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -1rem;
}

.ref-nav h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: #444;
}

.ref-nav ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ref-nav li {
  margin: 0;
}

.ref-nav a {
  text-decoration: none;
  background: #e3e3ff;
  color: #222;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: inline-block;
  transition: background 0.2s ease;
}

.ref-nav a:hover {
  background: #c6c6ff;
}

/* Content sections */
.ref-section {
  padding: 1.5rem 1.4rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  scroll-margin-top: 120px;
}

.ref-section:last-of-type {
  border-bottom: none;
}

.ref-section h2 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
  color: #222;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ref-section h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.2rem;
  color: #333;
}

.ref-section h4 {
  margin: 0.8rem 0 0.4rem;
  font-size: 1.05rem;
  color: #444;
}

.ref-section p {
  margin: 0.5rem 0;
  line-height: 1.7;
}

.ref-section ul,
.ref-section ol {
  margin: 0.5rem 0;
  padding-left: 1.8rem;
  line-height: 1.7;
}

.ref-section li {
  margin: 0.3rem 0;
}

/* Badges & notes */
.cat-tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #222;
  color: #fff;
  font-weight: 600;
}

.tagline {
  margin: 0.25rem 0 1rem;
  font-size: 0.95rem;
  color: #666;
  line-height: 1.5;
}

.note {
  background: #fff9f3;
  border-left: 3px solid #ffb366;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin: 1rem 0;
  line-height: 1.6;
}

.inline-demo {
  display: inline-block;
  padding: 0.25rem 0.4rem;
  background: #f4fff8;
  border-radius: 4px;
  border: 1px dashed #8fd4af;
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.deprecated {
  color: #b00020;
  font-weight: 600;
}

.pill {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eee;
  margin-right: 0.2rem;
  display: inline-block;
  margin-bottom: 0.2rem;
}

.live-example-box {
  margin: 0.5rem 0;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px dashed #ccc;
  background: #fbfbff;
  font-size: 0.85rem;
}

.demo-box {
  border: 1px solid #ddd;
  padding: 0.6rem;
  border-radius: 4px;
  margin-top: 0.4rem;
  background: #f9f9ff;
}

/* Tables */
.ref-main table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ref-main th,
.ref-main td {
  border: 1px solid #eee;
  padding: 0.6rem 0.8rem;
  vertical-align: top;
  text-align: left;
  white-space: nowrap;
}

.ref-main th {
  background: #f0f0ff;
  font-weight: 600;
  color: #222;
}

.ref-main tbody tr:hover {
  background: #fafafa;
}

.ref-main code {
  font-family: "Fira Code", Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  padding: 0.15rem 0.4rem;
  background: #f5f5f5;
  border-radius: 3px;
  color: #d63384;
}

.ref-main pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.5;
}

.ref-main pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 0.85rem;
}

/* ========= TABLET FIXES ========= */
@media (min-width: 601px) and (max-width: 1024px) {
  /* Ensure ref-main doesn't overflow */
  .ref-main {
    width: calc(100% - 2rem);
    margin: 1.5rem 1rem 3rem;
  }
  
  /* Adjust header for tablet */
  .ref-header {
    margin: -1rem -1rem 1rem;
    border-radius: 10px 10px 0 0;
  }
  
  /* Keep nav sticky on tablet */
  .ref-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -1rem;
  }
  
  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
}

/* ========= FOOTER ========= */
.site-footer {
  background: #111827;
  color: #ffffff;
  padding: 0.9rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  margin-top: auto;
}

.site-footer a {
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: #111827;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 999;
}

.back-to-top.is-visible {
  opacity: 0.9;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.back-to-top i {
  font-size: 1rem;
}

/* ========= MOBILE RESPONSIVE ========= */
@media (max-width: 900px) {
  .tiles {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .login-card {
    padding: 1.6rem 1.4rem 2rem;
  }
  
  header.topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .topbar-center {
    order: 3;
    width: 100%;
    text-align: center;
    padding-top: 0.2rem;
  }
  
  .topbar-right {
    font-size: 0.85rem;
  }
  
  .topbar-left img,
  .topbar-logo {
    width: 70px;
  }
  
  .ref-main {
    margin: 1rem 0.5rem 2rem;
    padding: 0 0.5rem 1rem;
    border-radius: 8px;
  }
  
  .ref-header {
    margin: -0.5rem -0.5rem 1rem;
    border-radius: 8px 8px 0 0;
    padding: 1rem 0.5rem;
  }
  
  .ref-header h1 {
    font-size: 1.4rem;
  }
  
  .ref-header p {
    font-size: 0.85rem;
  }
  
  /* Mobile: nav scrolls (not sticky) */
  .ref-nav {
    position: relative;
    margin: 0 -0.5rem;
    padding: 0.8rem 1rem 0.5rem;
  }
  
  .ref-nav h2 {
    font-size: 0.9rem;
  }
  
  .ref-nav ul {
    gap: 0.3rem;
  }
  
  .ref-nav a {
    font-size: 0.75rem;
    padding: 0.35rem 0.7rem;
  }
  
  .ref-section {
    padding: 1rem 0.8rem;
    scroll-margin-top: 20px;
  }
  
  .ref-section h2 {
    font-size: 1.2rem;
  }
  
  .ref-section h3 {
    font-size: 1.05rem;
  }
  
  .ref-main pre {
    font-size: 0.75rem;
    padding: 0.8rem;
  }
  
  .ref-main table {
    font-size: 0.85rem;
  }
  
  .ref-main th,
  .ref-main td {
    padding: 0.4rem 0.5rem;
  }
}
