/* ============================================================
   Micert.net — Global Stylesheet
   Dark theme + dark green accent
   ============================================================ */

/* ---- Custom Properties ------------------------------------ */
:root {
  --bg:          #0f1117;
  --bg-card:     #16191f;
  --bg-sidebar:  #12151b;
  --bg-input:    #1e2129;
  --bg-table:    #16191f;
  --bg-thead:    #1a1d25;
  --bg-hover:    #1e2229;
  --green:       #1a9e4a;
  --green-dark:  #136b32;
  --green-light: #22c55e;
  --green-muted: #1a3d28;
  --text:        #e2e8f0;
  --text-muted:  #8b9ab0;
  --text-dim:    #5a6a80;
  --border:      #252a35;
  --border-light:#2e3440;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #3b82f6;
  --success:     #22c55e;
  --radius:      8px;
  --radius-sm:   4px;
  --shadow:      0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --transition:  0.18s ease;
  --sidebar-w:   240px;
}

/* ---- Reset ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--green-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: #4ade80; }
img { max-width: 100%; }
ul, ol { list-style: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- Typography ------------------------------------------- */
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-muted); }
small { font-size: 0.82rem; color: var(--text-dim); }

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--green);
  color: #fff;
}
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-warning {
  background: rgba(245,158,11,0.15);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.3);
}
.btn-warning:hover { background: rgba(245,158,11,0.25); }
.btn-info {
  background: rgba(59,130,246,0.15);
  color: var(--info);
  border: 1px solid rgba(59,130,246,0.3);
}
.btn-info:hover { background: rgba(59,130,246,0.25); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ------------------------------------------------ */
.form-group { margin-bottom: 16px; }
label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,158,74,0.15);
}
input::placeholder { color: var(--text-dim); }
textarea { min-height: 100px; resize: vertical; }
.field-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}
.field-error.show { display: block; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ---- Cards ------------------------------------------------ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ---- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead { background: var(--bg-thead); }
th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
td.actions { white-space: nowrap; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }
.table-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
}

/* ---- Badges ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-success   { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-warning   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-danger    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-info      { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-secondary { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* ---- Flash messages --------------------------------------- */
.flash-container { margin-bottom: 20px; }
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.flash-success { background: rgba(34,197,94,0.12);  border-left: 3px solid var(--success); color: #86efac; }
.flash-error   { background: rgba(239,68,68,0.12);  border-left: 3px solid var(--danger);  color: #fca5a5; }
.flash-info    { background: rgba(59,130,246,0.12); border-left: 3px solid var(--info);    color: #93c5fd; }
.flash-warning { background: rgba(245,158,11,0.12); border-left: 3px solid var(--warning); color: #fcd34d; }
.flash-close { margin-left: auto; cursor: pointer; opacity: 0.6; font-size: 1.1rem; }
.flash-close:hover { opacity: 1; }

/* ============================================================
   PUBLIC LAYOUT
   ============================================================ */
.public-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,17,23,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.public-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green-light);
  letter-spacing: -0.03em;
}
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); }
.nav-links a.active { color: var(--green-light); }
.nav-links .btn { margin-left: 4px; }

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px 60px;
  text-align: center;
}
.hero h1 { font-size: 2.6rem; margin-bottom: 18px; line-height: 1.15; }
.hero h1 span { color: var(--green-light); }
.hero p { font-size: 1.1rem; margin-bottom: 32px; max-width: 600px; margin-left: auto; margin-right: auto; }
.hero-buttons { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }

.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 24px;
}
.section-title {
  text-align: center;
  margin-bottom: 40px;
}
.section-title h2 { margin-bottom: 8px; }
.section-title p { font-size: 1rem; }

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.service-card:hover { border-color: var(--green); box-shadow: 0 0 0 1px var(--green-muted); }
.service-icon { font-size: 2.2rem; margin-bottom: 14px; }
.service-card h3 { margin-bottom: 8px; color: var(--text); }
.service-price { font-size: 1.4rem; font-weight: 700; color: var(--green-light); margin-top: 12px; }
.service-status { font-size: 0.8rem; color: var(--success); margin-top: 4px; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.feature-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
}
.feature-item h4 { margin-bottom: 6px; color: var(--text); }
.feature-item p { font-size: 0.88rem; }

.public-footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---- Auth pages ------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  width: 100%;
  max-width: 440px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo a { font-size: 1.8rem; font-weight: 700; color: var(--green-light); }
.auth-box .card { padding: 32px; }
.auth-box h2 { margin-bottom: 6px; }
.auth-box p.subtitle { font-size: 0.9rem; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.88rem; color: var(--text-muted); }

/* ============================================================
   PANEL LAYOUT (member + admin)
   ============================================================ */
.panel-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo a { font-size: 1.2rem; font-weight: 700; color: var(--green-light); }
.sidebar-logo .site-tag { font-size: 0.72rem; color: var(--text-dim); display: block; margin-top: 2px; }

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-user .name { font-size: 0.9rem; font-weight: 600; }
.sidebar-user .role-tag { font-size: 0.75rem; color: var(--text-dim); text-transform: capitalize; }
.sidebar-user .balance-tag { font-size: 0.8rem; color: var(--green-light); margin-top: 4px; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-section {
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: color var(--transition), background var(--transition);
}
.sidebar-nav a:hover { color: var(--text); background: var(--bg-hover); }
.sidebar-nav a.active { color: var(--green-light); background: var(--green-muted); }
.sidebar-nav a .icon { width: 18px; text-align: center; opacity: 0.7; }

.sidebar-bottom {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-bottom a {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 0.85rem;
}
.sidebar-bottom a:hover { color: var(--danger); }

.panel-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.panel-topbar {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-balance { font-size: 0.85rem; color: var(--green-light); }

.panel-content { padding: 28px; flex: 1; }

/* Hamburger */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .sidebar-toggle { display: block; }
  .panel-main { margin-left: 0; }
}

/* ---- Stats row (dashboard) -------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Service availability (dashboard) --------------------- */
.avail-table td:first-child { color: var(--text); font-weight: 500; }
.avail-table .price { color: var(--green-light); font-weight: 600; }
.avail-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.avail-dot.on  { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.avail-dot.off { background: var(--danger); }

/* ---- Dual CPID form --------------------------------------- */
.cpid-form .optional-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.optional-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.generate-wrap { text-align: center; margin: 24px 0; }
.imei-helper { font-size: 0.78rem; color: var(--danger); margin-top: 4px; display: none; }
.imei-helper.show { display: block; }

/* Searchable product dropdown */
.product-dropdown { position: relative; }
.product-search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  outline: none;
}
.product-search-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(26,158,74,0.15); }
.product-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  display: none;
  box-shadow: var(--shadow-md);
}
.product-list.open { display: block; }
.product-option {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.product-option:hover { background: var(--bg-hover); }
.product-option .svc-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--green-muted);
  color: var(--green-light);
}
#product-hidden { display: none; }

/* ---- Confirm Modal ---------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; }
.modal-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.modal-row:last-of-type { border-bottom: none; }
.modal-row .label { color: var(--text-muted); }
.modal-row .value { font-weight: 500; color: var(--text); }
.modal-row .value.price { color: var(--green-light); font-size: 1rem; font-weight: 700; }
.modal-row .value.after { color: var(--warning); }
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  justify-content: flex-end;
}
.modal-result {
  margin-top: 18px;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: none;
}
.modal-result.success { background: rgba(34,197,94,0.1); color: var(--success); }
.modal-result.error   { background: rgba(239,68,68,0.1);  color: var(--danger); }
.modal-result a { color: var(--green-light); text-decoration: underline; }

/* ---- Pagination ------------------------------------------- */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ---- Filters ---------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 130px; }
.filter-bar select,
.filter-bar input { width: 100%; }

/* ---- Balance tabs ----------------------------------------- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--green-light); border-bottom-color: var(--green-light); }

/* ---- Code / pre blocks ------------------------------------ */
pre, code {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82rem;
}
pre {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  color: #a8d8a8;
}
.api-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
}
.api-key-value {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--green-light);
  word-break: break-all;
}

/* ---- Loading spinner -------------------------------------- */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Utility ---------------------------------------------- */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-green  { color: var(--green-light); }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---- Maintenance page ------------------------------------- */
.maintenance-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.maintenance-box { max-width: 500px; }
.maintenance-icon { font-size: 4rem; margin-bottom: 20px; }
.maintenance-box h1 { color: var(--warning); margin-bottom: 12px; }

/* ---- 403 / 404 ------------------------------------------- */
.error-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.error-code { font-size: 5rem; font-weight: 800; color: var(--border); line-height: 1; }
