/* SignApps CSS - Compact, Sleek iOS Mobile-First Design System */

:root {
  --bg-primary: #0b0e14;
  --bg-secondary: #121824;
  --bg-card: rgba(22, 30, 46, 0.9);
  --bg-card-hover: rgba(30, 42, 66, 0.95);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-active: #3b82f6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.25);
  --danger: #ef4444;
  --warning: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 13.5px;
}

html, body {
  width: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
}

.container {
  max-width: 680px; /* Compact width matching Image 2 */
  margin: 0 auto;
  padding: 0.85rem 0.65rem 2.5rem;
  width: 100%;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 1.15rem;
}

.header-badges {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.badge-wasm {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.3);
}

.badge-kv {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-status {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

h1 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.4;
}

/* Section Box */
.section-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 0.75rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  width: 100%;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.section-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.35;
}

/* App Grid: EXACT 2 COLUMNS ON ALL SCREENS (Just like Image 2!) */
.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.app-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  user-select: none;
  width: 100%;
}

.app-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.app-card.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 1px var(--primary), 0 2px 10px var(--primary-glow);
}

.app-card.selected::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: bold;
}

.app-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.app-info {
  flex-grow: 1;
  min-width: 0;
}

.app-name {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-meta {
  font-size: 0.7rem;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.app-size {
  display: inline-block;
  font-size: 0.62rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}

/* Tabs: Modern Segmented Control - Exactly 50% each */
.tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  width: 100%;
  gap: 3px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.48rem 0.35rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* API Box & UDID Row */
.api-box {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.udid-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}

.udid-row input {
  flex: 1;
  min-width: 0;
}

.udid-row .btn {
  flex-shrink: 0;
  padding: 0.52rem 0.65rem;
  font-size: 0.78rem;
}

/* Drop Zone: Native Label Container */
.dropzone {
  display: block;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: 1.15rem 0.75rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.dropzone.success {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.dropzone.success .dropzone-icon {
  color: #10b981;
}

.dropzone.success .dropzone-title {
  color: #34d399;
}

.dropzone-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.dropzone-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.dropzone-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* UDID Row: All 3 items on ONE single row! */
.udid-input-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}

.udid-input-row input {
  flex: 1;
  min-width: 0;
}

/* Form inputs */
.form-group {
  margin-top: 0.65rem;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: var(--accent);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-large {
  width: 100%;
  padding: 0.85rem;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

/* Certificate Preview Box */
.cert-preview-card {
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: none;
}

.cert-preview-card.visible {
  display: block;
}

.cert-item-card {
  transition: all 0.2s ease;
}

.cert-item-card.active-cert {
  border-color: var(--primary) !important;
  background: rgba(37, 99, 235, 0.12) !important;
}

.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.4rem;
}

.cert-title-group h4 {
  font-size: 0.85rem;
  font-weight: 700;
  word-break: break-word;
}

.cert-status-badge {
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-revoked {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.cert-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  font-size: 0.75rem;
}

.cert-item-label {
  color: var(--text-sub);
  margin-bottom: 0.05rem;
  font-size: 0.7rem;
}

.cert-item-value {
  color: var(--text-main);
  font-weight: 600;
  word-break: break-all;
}

/* Progress Box */
.progress-card {
  display: none;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-top: 0.85rem;
}

.progress-card.visible {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-message {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Result Modal / Box */
.result-card {
  display: none;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  padding: 1.15rem 0.85rem;
  margin-top: 0.85rem;
  text-align: center;
}

.result-card.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-icon {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.result-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
  margin: 0 auto 0.75rem;
}

/* Success Modal Popup Overlay */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
  animation: modalFadeIn 0.2s ease;
}

.modal-card {
  background: #141b2d;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.15rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7);
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-icon {
  font-size: 2.3rem;
  margin-bottom: 0.35rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.25rem;
}

.modal-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
}

/* Footer */
footer {
  margin-top: auto;
  text-align: center;
  padding: 1.25rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border-color);
}
