/* ============================================
   Lightjams LED Mapper — License Portal CSS
   Matches the LJLM website look and feel
   ============================================ */

:root {
  --primary: #00aeef;
  --primary-dark: #008ec4;
  --secondary: #fefefe;
  --dark: #0a0a0a;
  --darker: #050505;
  --light: #f0f0f0;
  --gray: #888;
  --card-bg: rgba(20, 20, 20, 0.9);
  --transition: all 0.3s ease;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.45);
  --border-radius: 12px;
  --max-width: 1200px;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

body {
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  color: var(--light);
  background-color: var(--dark);
  overflow-x: clip;
  padding-bottom: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
}

p { margin-bottom: 1rem; font-size: 1.05rem; font-weight: 300; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--primary-dark); }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* ============================================
   Navigation
   ============================================ */

.navbar {
  position: fixed;
  top: 0; left: 0; width: 100%;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 0;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: white;
}
.logo span { color: var(--primary); }

.nav-links {
  display: flex;
  list-style: none;
  align-items: center;
  gap: 0.3rem;
}

.nav-item { position: relative; }

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  transition: var(--transition);
  display: block;
}
.nav-link:hover { color: var(--primary); }

.nav-link.btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 0.55rem 1.2rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}
.nav-link.btn:hover {
  background: var(--primary-dark);
  color: white;
}

.nav-link-admin { color: var(--warning) !important; }
.nav-link-logout { opacity: 0.5; display: inline-flex; align-items: center; gap: 0.4rem; }
.nav-link-logout:hover { opacity: 1; color: var(--danger); }
.nav-link-logout svg { display: block; pointer-events: none; }
.nav-link-back { font-size: 0.85rem; opacity: 0.55; }
.nav-link-back:hover { opacity: 1; }

.nav-user-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  border-radius: 6px;
  transition: var(--transition);
}
.nav-user-label:hover { color: rgba(255, 255, 255, 0.75); background: rgba(255, 255, 255, 0.04); }
.nav-user-label svg { flex-shrink: 0; color: var(--success); }

.nav-user-mobile {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  transition: var(--transition);
}
.nav-user-mobile:hover { color: rgba(255, 255, 255, 0.75); }
.nav-user-mobile svg { flex-shrink: 0; color: var(--success); }

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0.4rem;
  line-height: 1;
  z-index: 1001;
}

/* ============================================
   Main Content
   ============================================ */

.portal-main {
  flex: 1;
  padding-top: 100px;
  padding-bottom: 3rem;
}

/* ============================================
   Cards & Panels
   ============================================ */

.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-header h2, .card-header h3 {
  margin-bottom: 0;
  color: var(--secondary);
}

.card-narrow {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.card-medium {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   Page Title
   ============================================ */

.page-title {
  font-size: 2.2rem;
  color: var(--secondary);
  margin-bottom: 2rem;
}
.page-title span { color: var(--primary); }

/* ============================================
   Alerts / Flash Messages
   ============================================ */

.alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  font-weight: 400;
  border: 1px solid;
}

.alert-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: var(--success); }
.alert-error   { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: var(--danger); }
.alert-info    { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: var(--info); }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--warning); }

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  color: var(--light);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--light);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.15);
}

.form-control::placeholder { color: var(--gray); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23777' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

select.form-control option {
  background: #1a1a1a;
  color: #f0f0f0;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-control[readonly] {
  background: rgba(255, 255, 255, 0.02);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--gray);
  cursor: default;
}

.form-help {
  display: block;
  font-size: 0.82rem;
  color: var(--gray);
  margin-top: 0.3rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-block;
  padding: 0.7rem 1.8rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow); color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }

.btn-warning { background: var(--warning); color: #111; }
.btn-warning:hover { background: #d97706; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--light);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 174, 239, 0.05);
}

.btn-sm { padding: 0.45rem 1rem; font-size: 0.82rem; }
.btn-block { display: block; width: 100%; }
.btn + .btn { margin-left: 0.5rem; }

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-table .btn-group {
  gap: 0.25rem;
  justify-content: flex-start;
}
.data-table .btn-group .btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.76rem;
  white-space: nowrap;
  margin-left: 0;
}
.data-table .btn-group .btn.btn-icon {
  padding: 0.28rem 0.38rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg {
  display: block;
  pointer-events: none;
}

/* ============================================
   Tables
   ============================================ */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table thead th {
  background: rgba(0, 174, 239, 0.06);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.85rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

table.data-table thead th a { cursor: pointer; user-select: none; }
table.data-table thead th a:hover { color: white; }
table.data-table thead th .sort-icon { font-size: 0.7em; margin-left: 4px; }

table.data-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s;
}
table.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

table.data-table td {
  padding: 0.75rem;
  color: var(--light);
  font-weight: 300;
  vertical-align: middle;
}

table.data-table th:first-child,
table.data-table td:first-child {
  min-width: 140px;
}

/* License state backgrounds */
tr.state-revoked { background: rgba(239, 68, 68, 0.08) !important; }
tr.state-retired { background: rgba(245, 158, 11, 0.06) !important; }
tr.state-unused  { background: rgba(59, 130, 246, 0.04) !important; }

/* ============================================
   Pagination
   ============================================ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--light);
  transition: var(--transition);
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 174, 239, 0.06);
}

.pagination .current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

.pagination .disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ============================================
   License Group Cards
   ============================================ */

.project-group {
  margin-bottom: 2.5rem;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid rgba(0, 174, 239, 0.2);
}

.project-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--secondary);
}
.project-header h2 span { color: var(--primary); }

.license-group {
  margin-bottom: 1rem;
  margin-left: 0.5rem;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: rgba(0, 174, 239, 0.04);
  border: 1px solid rgba(0, 174, 239, 0.12);
  border-radius: 10px 10px 0 0;
}

.group-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--secondary);
}
.group-header h3 span { color: var(--primary); }

.group-total {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

.group-body {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: none;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}

/* ============================================
   Badges
   ============================================ */

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-valid     { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-revoked   { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-activated { background: rgba(0,174,239,0.15); color: var(--success); }
.badge-unused    { background: rgba(255,255,255,0.08); color: var(--gray); }
.badge-retired   { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-permanent { background: rgba(34,197,94,0.1); color: var(--primary); }
.badge-rental    { background: rgba(245,158,11,0.1); color: rgb(144,0,255); }
.badge-expired   { background: rgba(239,68,68,0.2); color: var(--danger); }

/* ============================================
   Toolbar (search + filters)
   ============================================ */

.toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toolbar .search-box {
  flex: 1;
  min-width: 200px;
}

/* ============================================
   Modal / Confirmation Dialog
   ============================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #1a1a1a;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-bottom: 1rem;
  color: var(--secondary);
}

.modal-wide {
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal p { color: var(--light); font-size: 0.95rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  color: var(--gray);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  text-decoration: none;
  display: block;
}

.tab:hover { color: var(--light); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============================================
   Product Cards (Buy page)
   ============================================ */

.products-grid {
  display: grid;
  gap: 1rem;
}

.product-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  transition: var(--transition);
}
.product-card:hover {
  border-color: rgba(0, 174, 239, 0.2);
}

/* Product selector (buy.php) */
.product-selector {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 700px;
  margin: 0 auto;
}

.product-selector-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.75rem 2rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(0,174,239,0.04) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  transition: all 0.25s ease;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.product-selector-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  opacity: 0;
  background: linear-gradient(135deg, rgba(0,174,239,0.08) 0%, rgba(0,174,239,0.02) 100%);
  transition: opacity 0.25s ease;
}

.product-selector-card:hover {
  border-color: rgba(0, 174, 239, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 174, 239, 0.12), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.product-selector-card:hover::before {
  opacity: 1;
}

.product-selector-icon {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.product-selector-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
}

.product-selector-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.product-selector-body h3 {
  color: var(--secondary);
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.product-selector-body p {
  color: var(--gray);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.55;
}

.product-selector-arrow {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
  position: relative;
  z-index: 1;
}

.product-selector-card:hover .product-selector-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

@media (max-width: 600px) {
  .product-selector-card {
    padding: 1.25rem 1rem;
    gap: 1rem;
  }
  .product-selector-icon {
    width: 56px;
    height: 56px;
  }
  .product-selector-icon img {
    width: 56px;
    height: 56px;
  }
}

.product-info h4 {
  color: var(--secondary);
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.product-info p {
  color: var(--gray);
  font-size: 0.88rem;
  margin-bottom: 0;
}

.product-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  margin-right: 1rem;
}

.product-separator {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 1rem 0;
}

/* ============================================
   Stats row
   ============================================ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Space Grotesk', sans-serif;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

/* ============================================
   Footer
   ============================================ */

footer {
  padding: 2rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: auto;
}

.footer-bottom {
  text-align: center;
}

.footer-bottom p {
  color: var(--gray);
  font-size: 0.85rem;
  margin-bottom: 0;
}

/* ============================================
   Utility
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================
   Responsive — 768px
   ============================================ */

@media (max-width: 768px) {
  .mobile-toggle { display: block; }

  .nav-links {
    position: fixed;
    top: 64px;
    right: -100%;
    flex-direction: column;
    align-items: flex-start;
    background: var(--darker);
    width: 80%; max-width: 300px;
    height: calc(100vh - 64px);
    padding: 1.5rem;
    transition: var(--transition);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.4);
    gap: 0;
    overflow-y: auto;
  }
  .nav-links.active { right: 0; }

  .nav-item { width: 100%; margin: 0.4rem 0; }
  .nav-link { font-size: 1.1rem; width: 100%; }

  .nav-user-mobile { display: flex; }

  .nav-user-info { border-top: 1px solid rgba(255, 255, 255, 0.08); margin-top: 0.5rem; padding-top: 0.5rem; }
  .nav-user-label { max-width: none; font-size: 0.85rem; }

  .form-row { grid-template-columns: 1fr; }

  .product-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .product-price { margin-right: 0; }

  .page-title { font-size: 1.6rem; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .toolbar { flex-direction: column; }
  .toolbar .search-box { min-width: 100%; }

  .project-header, .group-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

@media (max-width: 576px) {
  .container { padding: 0 1.2rem; }
  .card { padding: 1.5rem; }
  .stats-row { grid-template-columns: 1fr; }
}
