/* ── Reset & Base ─────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  background-color: #f5f5f5;
  color: #333;
}

.hidden {
  display: none !important;
}

/* ── App Container ───────────────────────────────────────── */

#qwerty-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────── */

#qwerty-header {
  display: flex;
  align-items: center;
  padding: 10px 8px 10px 20px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#qwerty-logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-right: auto;
}

#qwerty-settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
  border-radius: 8px;
}

#qwerty-settings-btn:hover {
  color: #222;
}

#qwerty-settings-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* ── Navigation Menu ────────────────────────────────────── */

#nav-menu-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#nav-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
  border-radius: 8px;
}

#nav-menu-btn:hover {
  color: #222;
}

#nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 500;
  min-width: 200px;
  overflow: hidden;
}

#nav-menu.hidden {
  display: none;
}

#nav-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #555;
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}

#nav-menu a:hover {
  background: #f5f5f5;
  color: #111;
}

#nav-menu a.active {
  color: #4CAF50;
  font-weight: 700;
}

#nav-menu a.active svg {
  color: #4CAF50;
}

/* ── Welcome Screen ──────────────────────────────────────── */

#welcome-screen {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}

.welcome-content {
  text-align: center;
  max-width: 360px;
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.welcome-content h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.welcome-content p {
  margin: 0 0 24px;
  color: #666;
  font-size: 0.85rem;
  line-height: 1.5;
}

#upload-btn,
#create-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#upload-btn {
  background-color: #4CAF50;
  color: #fff;
}

#create-btn {
  background-color: #2196F3;
  color: #fff;
}

#upload-btn:active,
#create-btn:active {
  opacity: 0.85;
}

/* ── Main Screen & Toolbar ───────────────────────────────── */

#main-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
}

#toolbar button {
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #e8e8e8;
  color: #333;
}

#toolbar button:active {
  opacity: 0.8;
}

#add-btn {
  background-color: #4CAF50 !important;
  color: #fff !important;
}

/* ── Qwerty List ───────────────────────────────────────────── */

#qwerty-list {
  flex: 1;
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
}

.qwerty-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.15s;
}

.qwerty-item:active {
  background-color: #f0f0f0;
}

.qwerty-robot-id {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qwerty-robot-id.revealed {
  color: #4CAF50;
}

.qwerty-key-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: #e3f2fd;
  color: #1565c0;
  white-space: nowrap;
}

.qwerty-time {
  font-size: 0.72rem;
  color: #999;
  white-space: nowrap;
}

.qwerty-empty {
  text-align: center;
  padding: 40px 16px;
  color: #999;
  font-size: 0.85rem;
}

#security-notice {
  padding: 14px 18px;
  margin: 12px 12px 16px;
  background: #f0f7ff;
  border: 1px solid #d0e3f7;
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.6;
  color: #4a6a8a;
}

#security-notice p {
  margin: 0;
}

.qwerty-unlock {
  display: flex;
  justify-content: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.qwerty-unlock button {
  padding: 8px 20px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #fff3e0;
  color: #e65100;
}

.qwerty-unlock button:active {
  opacity: 0.8;
}

/* ── Modal (shared) ──────────────────────────────────────── */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.07);
}

.modal-content h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.modal-actions button:first-child {
  background-color: #4CAF50;
  color: #fff;
}

.modal-actions button:last-child {
  background-color: #e8e8e8;
  color: #333;
}

.modal-actions button:active {
  opacity: 0.85;
}

/* ── Form Fields ─────────────────────────────────────────── */

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #555;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-row label {
  margin-bottom: 0;
}

.generate-link {
  font-size: 0.75rem;
  font-weight: 700;
  color: #2196F3;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.generate-link:hover {
  color: #1769aa;
  text-decoration: underline;
}

.input-group {
  display: flex;
  gap: 6px;
}

.input-group input {
  flex: 1;
}

.toggle-vis {
  padding: 8px 10px;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  line-height: 1;
}

.toggle-vis:active {
  background: #eee;
}

.error-text {
  margin: 8px 0 0;
  padding: 8px;
  font-size: 0.8rem;
  color: #d32f2f;
  background-color: #ffebee;
  border-radius: 6px;
}

/* ── Detail Modal ────────────────────────────────────────── */

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.detail-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #888;
}

.detail-value {
  font-size: 0.85rem;
  text-align: right;
  word-break: break-all;
}

.detail-secure-section {
  padding-top: 12px;
}

.detail-secure-section h4 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: #d32f2f;
}

.detail-field {
  margin-bottom: 12px;
}

.detail-field .detail-label {
  display: block;
  margin-bottom: 6px;
}

.detail-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-value-row .detail-value {
  flex: 1;
  padding: 8px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 0.82rem;
  text-align: left;
}

.detail-value-row .detail-value.revealed {
  color: #4CAF50;
  background: #e8f5e9;
}

.btn-small {
  padding: 6px 14px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #2196F3;
  color: #fff;
  white-space: nowrap;
}

.btn-small:active {
  opacity: 0.85;
}

.detail-bottom-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.detail-bottom-actions button {
  flex: 1;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#delete-entry-btn {
  background-color: #f44336;
  color: #fff;
}

#close-detail-btn {
  background-color: #e8e8e8;
  color: #333;
}

/* ── Key Prompt Modal ────────────────────────────────────── */

#key-input {
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 4px;
}

#key-input:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15);
}

/* ── Settings Modal ──────────────────────────────────────── */

.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  font-size: 0.85rem;
  cursor: pointer;
}

.settings-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.settings-actions button {
  flex: 1;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  color: #333;
}

.settings-actions button:hover {
  background: #f5f5f5;
}

#clear-all-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #f44336;
  color: #fff;
}

#close-settings-btn {
  display: block;
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #e8e8e8;
  color: #333;
}

#qwerty-theme-select {
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
}

/* ── Dark Theme ──────────────────────────────────────────── */

body.dark {
  background-color: #1a1a2e;
  color: #e0e0e0;
}

.dark #qwerty-header {
  background-color: #16213e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark #qwerty-settings-btn {
  color: #aaa;
}

.dark #qwerty-settings-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.dark .welcome-content p {
  color: #aaa;
}

.dark #upload-btn {
  background-color: #388E3C;
}

.dark #create-btn {
  background-color: #1976D2;
}

.dark #toolbar {
  background-color: #16213e;
  border-bottom-color: #2a2a4a;
}

.dark #toolbar button {
  background-color: #2a2a4a;
  color: #e0e0e0;
}

.dark #add-btn {
  background-color: #388E3C !important;
  color: #fff !important;
}

.dark .qwerty-item {
  background: #16213e;
  border-bottom-color: #2a2a4a;
}

.dark .qwerty-item:active {
  background-color: #1a2744;
}

.dark .qwerty-key-badge {
  background-color: #1a2744;
  color: #64b5f6;
}

.dark .qwerty-time {
  color: #777;
}

.dark .qwerty-empty {
  color: #777;
}

.dark #security-notice {
  background: #1a2744;
  border-color: #2a3a5a;
  color: #8aa4c0;
}

.dark .qwerty-unlock {
  background: #16213e;
  border-bottom-color: #2a2a4a;
}

.dark .qwerty-unlock button {
  background-color: #3e2723;
  color: #ffab91;
}

.dark .modal-content {
  background: #1e1e3a;
  color: #e0e0e0;
}

.dark .modal-close {
  color: #aaa;
}

.dark .modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.dark .form-field input,
.dark .form-field select,
.dark #key-input,
.dark #qwerty-theme-select {
  background: #2a2a4a;
  color: #e0e0e0;
  border-color: #3a3a5a;
}

.dark .form-field label {
  color: #aaa;
}

.dark .toggle-vis {
  background: #2a2a4a;
  border-color: #3a3a5a;
  color: #e0e0e0;
}

.dark .generate-link {
  color: #64b5f6;
}

.dark .generate-link:hover {
  color: #90caf9;
}

.dark .error-text {
  background-color: #4a1c1c;
  color: #ef9a9a;
}

.dark .detail-row {
  border-bottom-color: #2a2a4a;
}

.dark #nav-menu-btn {
  color: #aaa;
}

.dark #nav-menu-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.dark #nav-menu {
  background: #1e1e3a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.dark #nav-menu a {
  color: #bbb;
}

.dark #nav-menu a:hover {
  background: #2a2a4a;
  color: #fff;
}

.dark #nav-menu a.active {
  color: #66bb6a;
}

.dark #nav-menu a.active svg {
  color: #66bb6a;
}

.dark .detail-label {
  color: #999;
}

.dark .detail-secure-section {
  border-top-color: #2a2a4a;
}

.dark .detail-value-row .detail-value {
  background: #2a2a4a;
}

.dark .detail-value-row .detail-value.revealed {
  background: #1b3a1b;
  color: #81c784;
}

.dark .modal-actions button:last-child,
.dark #close-detail-btn,
.dark #close-settings-btn {
  background-color: #2a2a4a;
  color: #e0e0e0;
}

.dark .btn-small {
  background-color: #1976D2;
}

.dark #delete-entry-btn,
.dark #clear-all-btn {
  background-color: #c62828;
}

.dark .settings-actions button {
  background: #2a2a4a;
  border-color: #3a3a5a;
  color: #e0e0e0;
}

.dark .settings-actions button:hover {
  background: #3a3a5a;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (min-width: 600px) {
  .modal-content {
    max-width: 440px;
  }

  .qwerty-item {
    padding: 14px 24px;
  }

  #toolbar {
    padding: 12px 24px;
  }
}

.app-version {
  margin-top: 16px;
  font-size: 11px;
  color: #999;
  text-align: center;
}
