/* admin.css - KeyChief Admin v2.2 */

@font-face {
  font-family: 'Nimbus Sans';
  src: url('/assets/nimbus-sans.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}

:root {
  --bg: rgba(10,14,20,0.98);
  --stroke: rgba(255,255,255,0.10);
  --stroke2: rgba(255,255,255,0.06);
  --text: rgba(240,246,255,0.94);
  --muted: rgba(170,190,220,0.75);
  --btn: rgba(255,255,255,0.06);
  --btn2: rgba(255,255,255,0.12);
  --primary: rgba(43,118,255,0.22);
  --primaryStroke: rgba(43,118,255,0.45);
  --danger: rgba(255,77,109,0.20);
  --dangerStroke: rgba(255,77,109,0.45);
  --success: rgba(34,227,138,0.20);
  --successStroke: rgba(34,227,138,0.45);
  --warning: rgba(255,193,7,0.20);
  --warningStroke: rgba(255,193,7,0.45);
  --shadow: 0 18px 60px rgba(0,0,0,0.55);
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

html, body {
  width: 100%;
  height: 100%;
  background: #0a0e14;
  color: var(--text);
  font-family: 'Nimbus Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Top Bar */
.topbar {
  height: 60px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--stroke2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  -webkit-app-region: drag;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  -webkit-app-region: no-drag;
}

.logo {
  height: 36px;
  width: auto;
  display: block;
}

.pill {
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke2);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-app-region: no-drag;
}

.webhookLabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.webhookInput {
  width: 380px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--stroke2);
  background: rgba(0,0,0,0.25);
  color: var(--muted);
  font-size: 11px;
  outline: none;
}

.iconBtn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--stroke2);
  background: var(--btn);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: all 0.15s ease;
}

.iconBtn:hover {
  background: var(--btn2);
  transform: scale(1.05);
}

.iconBtn.danger {
  border-color: var(--dangerStroke);
  background: var(--danger);
}

/* Tabs */
.tabs {
  padding: 12px 20px 0;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--stroke2);
  flex-shrink: 0;
}

.tab {
  padding: 10px 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.tab:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border-color: var(--stroke2);
  border-bottom-color: transparent;
}

/* Pages */
.page {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 20px;
  min-height: 0;
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* Card */
.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--stroke2);
  border-radius: 16px;
  padding: 16px;
  min-height: 0;
}

.cardTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.cardTitle {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.small {
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.rowInline {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Buttons */
.btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--stroke2);
  background: var(--btn);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover:not(:disabled) {
  background: var(--btn2);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--primaryStroke);
  background: var(--primary);
  color: rgba(100,150,255,1);
}

.btn.danger {
  border-color: var(--dangerStroke);
  background: var(--danger);
  color: rgba(255,100,130,1);
}

.btn.success {
  border-color: var(--successStroke);
  background: var(--success);
  color: rgba(50,240,160,1);
}

.btnLarge {
  height: 44px;
  font-size: 14px;
  padding: 0 24px;
}

/* Inputs - Match UI theme */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke2);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
}

select {
  cursor: pointer;
  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='%23aabedd' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: background-position 0.2s ease;
}

/* Fixed dropdown arrow animation */
select:focus {
  background-position: right 10px center;
}

select option {
  background: #1a1e28;
  color: var(--text);
  padding: 8px;
}

select optgroup {
  background: #141820;
  color: var(--muted);
  font-weight: 600;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primaryStroke);
  background: rgba(0,0,0,0.35);
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.searchInput {
  min-width: 320px;
  height: 36px;
}

/* Table */
.tableWrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--stroke2);
  border-radius: 12px;
  background: rgba(0,0,0,0.15);
  min-height: 0;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tbl thead th {
  position: sticky;
  top: 0;
  background: rgba(10,14,20,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--stroke);
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 10;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.tbl tbody td {
  border-bottom: 1px solid var(--stroke2);
  padding: 12px 14px;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tbl tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.tbl tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

.tbl tbody tr.sel {
  background: rgba(43,118,255,0.12);
  outline: 2px solid var(--primaryStroke);
  outline-offset: -2px;
}

.tbl tbody tr.sel td {
  border-color: var(--primaryStroke);
}

/* Status Colors */
.status-active {
  color: rgba(34,227,138,0.95) !important;
  font-weight: 600;
}

.status-canceled {
  color: rgba(255,193,7,0.95) !important;
  font-weight: 600;
}

.status-expired {
  color: rgba(255,77,109,0.95) !important;
  font-weight: 600;
}

.empty {
  text-align: center !important;
  color: var(--muted);
  padding: 40px !important;
  font-style: italic;
}

/* Form */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.field.span2 {
  grid-column: 1 / -1;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
  max-height: 200px;
}

.fieldHint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  margin-top: -4px;
}

.infoBox {
  padding: 12px;
  background: rgba(43,118,255,0.08);
  border: 1px solid var(--primaryStroke);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
}

/* Bottom Bar */
.bottomBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--stroke2);
  flex-shrink: 0;
}

/* Modal - Match UI theme */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modalContent {
  width: 600px;
  max-width: calc(100% - 40px);
  max-height: calc(100% - 40px);
  background: var(--bg);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modalContent.small {
  width: 400px;
}

.modalHeader {
  padding: 20px 24px;
  border-bottom: 1px solid var(--stroke2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modalHeader h3 {
  font-size: 18px;
  font-weight: 700;
}

.closeBtn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--stroke2);
  background: var(--btn);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: all 0.15s ease;
}

.closeBtn:hover {
  background: var(--btn2);
  transform: scale(1.05);
}

.modalBody {
  padding: 24px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modalFooter {
  padding: 16px 24px;
  border-top: 1px solid var(--stroke2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.notesDisplay {
  padding: 16px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--stroke2);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 100px;
  user-select: text;
  -webkit-user-select: text;
}

/* Toast - Fixed animation */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 400px;
  padding: 14px 18px;
  background: rgba(10,14,20,0.95);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 13px;
  z-index: 9999;
  display: none;
  animation: toastIn 0.3s ease;
}

.toast.show {
  display: block;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Checkbox styling */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: rgba(43,118,255,0.8);
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) rgba(0,0,0,0.2);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.2);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* Responsive */
@media (max-width: 1200px) {
  .form {
    grid-template-columns: 1fr;
  }
  
  .field.span2 {
    grid-column: 1;
  }
  
  .searchInput {
    min-width: 220px;
  }
  
  .webhookInput {
    width: 280px;
  }
}

/* Create > Type locked — render like an input (blue left bar), no highlight/click */
#createType{
  width: 100%;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--stroke2);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  min-height: 40px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  user-select: none !important;
  -webkit-user-select: none !important;
  pointer-events: none !important;
  cursor: default !important;
}

#createType::before{
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(43,118,255,0.42);
  box-shadow: inset 0 0 0 1px rgba(43,118,255,0.18);
}

#createTypeText{
  display: block;
  padding-left: 2px;
  opacity: 0.9;
  user-select: none !important;
  -webkit-user-select: none !important;
}
