/* JWT Decoder Styles */

/* ==================== Base Layout ==================== */

html {
  background-color: #0d9488;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  position: relative;
}

/* Animated gradient background - fixed position to prevent scroll issues */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 50%, rgba(13, 148, 136, 0.3) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(15, 118, 110, 0.3) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}

/* ==================== Header ==================== */

.header {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: var(--space-4) 0;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: white;
  transition: transform var(--transition-base);
}

.logo-link:hover {
  transform: scale(1.05);
}

.logo-text {
  color: white;
}

.logo-dot {
  color: #fbbf24;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.title {
  flex: 1;
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: white;
  margin: 0;
}

/* ==================== Tab Navigation ==================== */

.tabs-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: var(--space-2) 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-6);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: all var(--transition-base);
}

.tab-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
  color: white;
  border-bottom-color: white;
}

.tab-icon {
  font-size: var(--text-2xl);
}

.tab-label {
  white-space: nowrap;
}

/* ==================== JWT Input Bar ==================== */

.jwt-input-bar {
  flex-shrink: 0;
  z-index: 10;
  margin-bottom: var(--space-4);
}

.jwt-input-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
}

.jwt-input-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  position: relative;
}

.jwt-token-input {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.4;
  color: var(--color-gray-900);
  resize: vertical;
  word-break: break-all;
  transition: all var(--transition-base);
}

.jwt-token-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.jwt-token-input::placeholder {
  color: var(--color-gray-500);
}

.jwt-input-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Auto-execute toggle */
.auto-execute-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all var(--transition-base);
  user-select: none;
  line-height: 1;
}

.auto-execute-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.auto-execute-toggle:has(input:checked) {
  background: rgba(16, 185, 129, 0.3);
  border-color: rgba(16, 185, 129, 0.5);
}

.auto-execute-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #10b981;
  margin: 0;
  cursor: pointer;
}

.auto-execute-label {
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.02em;
}

/* JWT Error */
.jwt-error {
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
  border-radius: var(--radius-md);
  color: #dc2626;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: opacity var(--transition-base);
  position: relative;
}

.jwt-error:empty {
  display: none !important;
}

/* Security Notice */
.security-notice {
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  margin-bottom: var(--space-3);
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--color-success);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  position: relative;
}

/* ==================== Page Body ==================== */

.page-body {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.ad-sidebar {
  display: none;
}

.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Claims tab: no internal scroll — let main-content scroll everything */
.tab-content[data-tab-content="claims"] {
  overflow-y: visible;
  flex: none;
}

/* ==================== JWT Results ==================== */

.jwt-result-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}

/* Desktop: 2-column layout with equal heights */
@media (min-width: 1024px) {
  .jwt-result-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    column-gap: var(--space-4);
    row-gap: 0;
    align-items: stretch;
  }

  /* Left column: Header + Signature + Token Info stacked */
  #panel-header {
    grid-column: 1;
    grid-row: 1;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-bottom: -1px;
  }

  #panel-signature {
    grid-column: 1;
    grid-row: 2;
    border-radius: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 0;
    margin-bottom: -1px;
  }

  #panel-info {
    grid-column: 1;
    grid-row: 3;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 0;
  }

  /* Remove individual shadows from left panels */
  #panel-header,
  #panel-signature,
  #panel-info {
    box-shadow: none;
  }

  /* Apply combined shadow to create one unified panel look */
  #panel-header {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  /* Right column: Payload spans all 3 rows and matches total height */
  #panel-payload {
    grid-column: 2;
    grid-row: 1 / 4;
    display: flex;
    flex-direction: column;
  }

  /* Payload body should scroll when content exceeds left total height */
  #panel-payload .jwt-panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }
}

.jwt-panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.jwt-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(15, 118, 110, 0.1));
  border-bottom: 1px solid var(--color-border);
}

.jwt-panel-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* JWT 3-part color coding (jwt.io style) */
.dot-header {
  background: #fb015b;
}

.dot-payload {
  background: #d63aff;
}

.dot-signature {
  background: #00b9f1;
}

.dot-info {
  background: var(--color-success);
}

.jwt-panel-title {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-gray-900);
  flex: 1;
  margin: 0;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: var(--space-1);
  cursor: pointer;
  font-size: var(--text-lg);
  opacity: 0.6;
  transition: all var(--transition-base);
}

.btn-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

.jwt-panel-body {
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  flex: 1;
}

/* Custom scrollbar styling */
.jwt-panel-body::-webkit-scrollbar {
  width: 8px;
}

.jwt-panel-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.jwt-panel-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.jwt-panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Firefox scrollbar */
.jwt-panel-body {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);
}

/* Mobile: Show all content without scrolling, reorder panels */
@media (max-width: 1023px) {
  /* Remove max-height to show all content */
  .jwt-panel .jwt-panel-body {
    max-height: none;
    overflow-y: visible;
  }

  /* Reorder panels for mobile: Payload → Token Info → Header → Signature */
  #panel-payload {
    order: 1;
  }

  #panel-info {
    order: 2;
  }

  #panel-header {
    order: 3;
  }

  #panel-signature {
    order: 4;
  }

  /* Remove border radius adjustments for mobile (all panels separate) */
  #panel-header,
  #panel-signature,
  #panel-info {
    border-radius: var(--radius-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 0;
    margin-top: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }
}

/* Desktop: Left panels determine height, right panel scrolls */
@media (min-width: 1024px) {
  /* Left column panels - no scrolling, show all content, no max-height */
  #panel-header .jwt-panel-body,
  #panel-signature .jwt-panel-body,
  #panel-info .jwt-panel-body {
    max-height: none;
    overflow-y: visible;
  }

  /* Payload body - matches left total height, scrolls if content overflows */
  #panel-payload .jwt-panel-body {
    flex: 1;
    overflow-y: auto;
  }
}

.jwt-json-output {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  color: var(--color-gray-800);
}

/* ==================== JSON Syntax Highlighting ==================== */

.json-key {
  color: #3b82f6;
}

.json-string {
  color: #10b981;
}

.json-number {
  color: #f59e0b;
}

.json-boolean {
  color: #0d9488;
}

.json-null {
  color: #0d9488;
}

.json-punctuation {
  color: var(--color-gray-500);
}


/* ==================== Signature Info ==================== */

.jwt-signature-info {
  font-size: var(--text-sm);
}

.sig-algorithm {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.sig-algorithm-name {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--color-gray-900);
}

.sig-algorithm-type {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
}

.sig-description {
  color: var(--color-gray-600);
  margin-bottom: var(--space-3);
}

.sig-raw {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-gray-500);
  word-break: break-all;
  padding: var(--space-3);
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.sig-note {
  font-size: var(--text-xs);
  color: var(--color-gray-500);
  font-style: italic;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-md);
}

/* ==================== Token Info Grid ==================== */

.jwt-info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.info-label {
  font-weight: var(--font-semibold);
  color: var(--color-gray-600);
  white-space: nowrap;
}

.info-value {
  font-family: var(--font-mono);
  color: var(--color-gray-900);
  word-break: break-all;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  font-family: var(--font-sans);
}

.status-valid {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.status-expired {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.status-not-yet {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

/* ==================== Claims Reference ==================== */

.claims-container {
  padding: var(--space-6);
}

.claims-category {
  break-inside: avoid;
  margin-bottom: var(--space-6);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: var(--space-5);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.claims-category h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-3);
  color: var(--color-gray-900);
  margin-top: 0;
}

.claims-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  table-layout: fixed;
}

.claims-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.claims-table td:first-child {
  font-family: var(--font-mono);
  font-weight: var(--font-semibold);
  color: var(--color-primary);
  white-space: nowrap;
  width: 100px;
}

.claims-table td:last-child {
  color: var(--color-gray-700);
}

.claims-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==================== Status Bar ==================== */

.status-bar {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding: var(--space-2) 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.status-content {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  font-size: var(--text-sm);
}

.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-label {
  color: rgba(255, 255, 255, 0.8);
  font-weight: var(--font-medium);
}

#token-length,
#token-parts,
#status-text {
  color: white;
  font-weight: var(--font-semibold);
}

/* ==================== Responsive Design ==================== */

/* Mobile (<768px) */
@media (max-width: 767px) {
  body {
    height: auto;
    overflow-y: auto;
  }

  .title {
    font-size: var(--text-lg);
  }

  .jwt-input-actions {
    width: 100%;
    justify-content: space-between;
  }

  .status-content {
    gap: var(--space-3);
    font-size: var(--text-xs);
  }

  .jwt-result-container {
    gap: var(--space-3);
    display: flex;
    flex-direction: column;
  }

  .jwt-panel-body {
    padding: var(--space-3) var(--space-4);
  }

  .jwt-json-output {
    font-size: var(--text-xs);
  }

  .jwt-panel-title {
    font-size: var(--text-sm);
  }
}

/* Tablet (768-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .title {
    font-size: var(--text-xl);
  }
}

/* Desktop (1024-1399px) */
@media (min-width: 1024px) {
  .claims-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
    align-items: start;
  }

  .claims-category {
    break-inside: auto;
  }
}

/* Wide (≥1400px) - Show ad sidebars */
@media (min-width: 1400px) {
  .page-body {
    grid-template-columns: 200px 1fr 200px;
    gap: var(--space-4);
  }

  .ad-sidebar {
    display: block;
  }

  .ad-sticky {
    position: sticky;
    top: var(--space-4);
  }

  .ad-placeholder {
    width: 160px;
    height: 600px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    color: rgba(255, 255, 255, 0.5);
    font-size: var(--text-xs);
    text-align: center;
    padding: var(--space-3);
  }
}

/* ==================== Dark Mode ==================== */

html[data-theme="dark"] { background-color: #0f172a; }

[data-theme="dark"] body {
  background: #0f172a;
}

[data-theme="dark"] body::before {
  background: radial-gradient(circle at 20% 50%, rgba(26, 26, 62, 0.3) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(45, 27, 78, 0.3) 0%, transparent 50%);
}

[data-theme="dark"] .jwt-token-input {
  background: var(--color-gray-800);
  color: var(--color-gray-100);
  border-color: var(--color-gray-600);
}

[data-theme="dark"] .jwt-token-input::placeholder {
  color: var(--color-gray-500);
}

[data-theme="dark"] .jwt-error {
  background: rgba(239, 68, 68, 0.2);
  border-left-color: #f87171;
  color: #fca5a5;
}

[data-theme="dark"] .security-notice {
  background: rgba(16, 185, 129, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .jwt-panel {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .jwt-panel-header {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), rgba(15, 118, 110, 0.15));
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .jwt-panel-title {
  color: var(--color-gray-100);
}

[data-theme="dark"] .jwt-json-output {
  color: var(--color-gray-100);
}

[data-theme="dark"] .json-key {
  color: #60a5fa;
}

[data-theme="dark"] .json-string {
  color: #34d399;
}

[data-theme="dark"] .json-number {
  color: #fbbf24;
}

[data-theme="dark"] .json-boolean,
[data-theme="dark"] .json-null {
  color: #2dd4bf;
}

[data-theme="dark"] .sig-algorithm-name,
[data-theme="dark"] .sig-description {
  color: var(--color-gray-100);
}

[data-theme="dark"] .sig-raw {
  background: var(--color-gray-800);
  color: var(--color-gray-400);
}

[data-theme="dark"] .sig-note {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-gray-300);
}

[data-theme="dark"] .info-label {
  color: var(--color-gray-400);
}

[data-theme="dark"] .info-value {
  color: var(--color-gray-100);
}

[data-theme="dark"] .claims-category {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .claims-category h3 {
  color: var(--color-gray-100);
}

[data-theme="dark"] .claims-table td:first-child {
  color: #60a5fa;
}

[data-theme="dark"] .claims-table td:last-child {
  color: var(--color-gray-300);
}

[data-theme="dark"] .claims-table td {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Dark mode scrollbar styling */
[data-theme="dark"] .jwt-panel-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .jwt-panel-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .jwt-panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .jwt-panel-body {
  scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

/* Dark mode: left panel borders (desktop only) */
@media (min-width: 1024px) {
  [data-theme="dark"] #panel-signature,
  [data-theme="dark"] #panel-info {
    border-top-color: rgba(255, 255, 255, 0.08);
  }
}

/* Dark mode: mobile panels */
@media (max-width: 1023px) {
  [data-theme="dark"] #panel-header,
  [data-theme="dark"] #panel-signature,
  [data-theme="dark"] #panel-info {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
}

/* ── About/Related fix: allow scrolling past tool UI ─────────────────────── */
.main-content { overflow-y: auto; }
.panels-container { min-height: clamp(350px, 60vh, 800px); }

/* ── Compact header ─────────────────────────────────────────────────────── */
.header { padding: var(--space-1) 0; }
.logo-link { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); }
.title { font-size: var(--text-sm); }

/* ── Mobile: natural page scroll + usable editor height ─────────────────── */
@media (max-width: 767px) {
  body { height: auto; min-height: 100vh; overflow-y: auto; }
  .page-body { overflow: visible; }
  .main-content { overflow: visible !important; padding-bottom: var(--space-8); }
  .panel { min-height: 42vh; }
}
