/**
 * Popup UI Styles
 * Based on Binect Innovation BrandBook
 */

:root {
  /* Core Colors */
  --binect-blue: #4A90E2;
  --binect-blue-deep: #2C5F8D;
  --neutral-ink: #1A1A1A;
  --paper: #FFFFFF;
  --light-bg: #F8F9FA;

  /* Accent Colors */
  --signal-green: #4CAF50;
  --cyan: #00BCD4;
  --red: #E53935;

  /* Text */
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-light: #999999;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Border */
  --border-radius: 8px;
  --border-color: #E0E0E0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--paper);
  width: 380px;
  min-height: 400px;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  background: var(--light-bg);
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--binect-blue-deep);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--binect-blue);
  background: var(--paper);
  color: var(--binect-blue);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--binect-blue);
  color: var(--paper);
}

.icon-btn:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
}

.icon-btn svg {
  display: block;
}

.icon-btn.refreshing svg {
  animation: spin 1s linear infinite;
}

/* Archive Toggle Button */
.toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--binect-blue);
  background: var(--paper);
  color: var(--binect-blue);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-btn:hover {
  background: var(--binect-blue);
  color: var(--paper);
}

.toggle-btn:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
}

.toggle-btn.active {
  background: var(--binect-blue);
  color: var(--paper);
}

.toggle-btn.active:hover {
  background: var(--binect-blue-deep);
  border-color: var(--binect-blue-deep);
}

.toggle-btn svg {
  display: block;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Header actions */
.header-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

/* Pin Reminder Banner */
.pin-reminder {
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  border-bottom: 1px solid var(--binect-blue);
  padding: var(--spacing-sm) var(--spacing-md);
}

.pin-reminder-content {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
}

.pin-reminder-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.pin-reminder-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
}

.pin-reminder-text .puzzle-icon {
  font-size: 11px;
}

.pin-reminder-dismiss {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  margin-left: var(--spacing-xs);
  flex-shrink: 0;
}

.pin-reminder-dismiss:hover {
  color: var(--text-primary);
}

/* Views */
.view {
  flex: 1;
  padding: var(--spacing-lg);
}

/* Info Text */
.info-text {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  text-align: center;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--binect-blue);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Password Input Wrapper */
.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  padding-right: 44px; /* Make room for the eye icon */
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
}

.password-toggle:hover {
  background: var(--light-bg);
  color: var(--binect-blue);
}

.password-toggle:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
}

.password-toggle svg {
  display: block;
  pointer-events: none;
}

/* Buttons */
.btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-height: 44px; /* Accessibility: touch target size */
}

.btn:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--binect-blue);
  color: var(--paper);
}

.btn-primary:hover {
  background: var(--binect-blue-deep);
}

.btn-primary:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--light-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-large {
  padding: var(--spacing-md);
  font-size: 16px;
  min-height: 48px;
}

.btn-small {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 12px;
  min-height: 36px;
}

/* PDF Info */
.content-section {
  margin-bottom: var(--spacing-lg);
}

.pdf-info {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--light-bg);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-md);
}

.pdf-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.pdf-details {
  flex: 1;
  min-width: 0;
}

.pdf-filename {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--spacing-xs);
}

.pdf-timestamp {
  font-size: 11px;
  color: var(--text-light);
  margin-top: var(--spacing-xs);
}

/* PDF List */
.pdf-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.pdf-count {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.pdf-list {
  max-height: 280px;
  overflow-y: auto;
}

.pdf-list-item {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--light-bg);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-sm);
  transition: background 0.2s;
}

.pdf-list-item:last-child {
  margin-bottom: 0;
}

.pdf-list-item:hover {
  background: var(--border-color);
}

/* Status-specific item styles */
.pdf-list-item.uploading {
  opacity: 0.7;
}

.pdf-list-item.in-basket {
  background: rgba(74, 144, 226, 0.1);
  border-left: 3px solid var(--binect-blue);
}

.pdf-list-item.in-production {
  background: rgba(0, 188, 212, 0.1);
  border-left: 3px solid var(--cyan);
}

.pdf-list-item.sent {
  background: rgba(76, 175, 80, 0.1);
  border-left: 3px solid var(--signal-green);
}

.pdf-list-item.canceled {
  background: rgba(153, 153, 153, 0.1);
  border-left: 3px solid var(--text-light);
}

.pdf-list-item.failed {
  background: rgba(229, 57, 53, 0.1);
  border-left: 3px solid var(--red);
}

.pdf-item-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.pdf-item-details {
  flex: 1;
  min-width: 0;
}

.pdf-item-filename {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.pdf-item-status {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 2px;
}

.pdf-item-status.success {
  color: var(--signal-green);
}

.pdf-item-status.error {
  color: var(--red);
}

.pdf-item-status.in-basket {
  color: var(--binect-blue);
}

.pdf-item-status.in-production {
  color: var(--cyan);
}

.pdf-item-status.sent {
  color: var(--signal-green);
}

.pdf-item-status.canceled {
  color: var(--text-light);
}

.pdf-item-status.failed {
  color: var(--red);
}

/* Error details for erroneous documents */
.pdf-item-error {
  font-size: 10px;
  color: var(--red);
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(229, 57, 53, 0.08);
  border-radius: 3px;
  line-height: 1.3;
}

/* Price display */
.pdf-price {
  font-weight: 600;
  color: var(--binect-blue-deep);
}

/* Local tag - clickable to check server */
.tag-local {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--light-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  vertical-align: middle;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-local:hover {
  background: var(--binect-blue);
  color: white;
  border-color: var(--binect-blue);
}

.tag-local:active {
  transform: scale(0.95);
}

.tag-local.checking {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-text);
  cursor: wait;
}

.tag-local.synced {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-text);
}

/* Recipient address */
.pdf-item-recipient {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Section headers */
.pdf-section {
  margin-bottom: var(--spacing-md);
}

.pdf-section:last-child {
  margin-bottom: 0;
}

.pdf-section-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.pdf-section-completed {
  opacity: 0.8;
}

.pdf-section-completed .pdf-section-header {
  color: var(--text-light);
}

.pdf-item-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.btn-send-item {
  padding: 6px 12px;
  font-size: 11px;
  min-height: auto;
  background: var(--binect-blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-send-item:hover {
  background: var(--binect-blue-deep);
}

.btn-send-item:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}

.btn-dismiss {
  padding: 4px 8px;
  font-size: 10px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-dismiss:hover {
  background: var(--light-bg);
  color: var(--text-secondary);
}

/* Archive button */
.btn-archive {
  padding: 4px 8px;
  font-size: 10px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-archive:hover {
  background: var(--light-bg);
  color: var(--text-secondary);
}

/* Restore button */
.btn-restore {
  padding: 6px 12px;
  font-size: 11px;
  min-height: auto;
  background: var(--binect-blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-restore:hover {
  background: var(--binect-blue-deep);
}

/* Delete from server button */
.btn-delete-server {
  padding: 4px 8px;
  font-size: 10px;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-server:hover {
  background: var(--red);
  color: white;
}

/* Order button */
.btn-order-item {
  padding: 6px 12px;
  font-size: 11px;
  min-height: auto;
  background: var(--signal-green);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 500;
}

.btn-order-item:hover {
  background: #43a047;
}

.btn-order-item:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}

/* Refresh button */
.btn-refresh-item {
  padding: 6px 12px;
  font-size: 11px;
  min-height: auto;
  background: var(--light-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh-item:hover {
  background: var(--border-color);
  border-color: var(--text-light);
}

/* Remove button */
.btn-remove {
  opacity: 0.7;
}

/* Status Messages */
.status-message {
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  text-align: center;
  margin-top: var(--spacing-md);
}

.status-message.uploading {
  background: rgba(0, 188, 212, 0.1);
  color: var(--cyan);
  border: 1px solid var(--cyan);
}

.status-message.success {
  background: rgba(76, 175, 80, 0.1);
  color: var(--signal-green);
  border: 1px solid var(--signal-green);
}

.status-message.error {
  background: rgba(229, 57, 53, 0.1);
  color: var(--red);
  border: 1px solid var(--red);
}

.error-message {
  padding: var(--spacing-sm);
  background: rgba(229, 57, 53, 0.1);
  color: var(--red);
  border-radius: var(--border-radius);
  font-size: 12px;
  margin-top: var(--spacing-sm);
}

/* Settings */
.settings-section {
  border-top: 1px solid var(--border-color);
  padding-top: var(--spacing-md);
}

/* Footer */
.footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer-link {
  font-size: 12px;
  color: var(--binect-blue);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-link:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Footer button styled as link */
.footer-link-btn {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--binect-blue);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.footer-link-btn:hover {
  text-decoration: underline;
}

.footer-link-btn:focus {
  outline: 2px solid var(--binect-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Issue Report Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--paper);
  border-radius: var(--border-radius);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  background: var(--light-bg);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--spacing-md);
  overflow-y: auto;
  flex: 1;
}

.modal-body .form-group {
  margin-bottom: var(--spacing-md);
}

.modal-body textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
}

.modal-body textarea:focus {
  outline: none;
  border-color: var(--binect-blue);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.submit-link {
  font-size: 13px;
  color: var(--binect-blue);
  text-decoration: none;
}

.submit-link:hover {
  text-decoration: underline;
}

/* Context Sections */
.context-sections {
  margin-top: var(--spacing-md);
}

.context-sections h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
}

.context-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.context-section {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
}

.context-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--light-bg);
  padding: var(--spacing-xs) var(--spacing-sm);
}

.context-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs);
}

.context-toggle:hover {
  color: var(--binect-blue);
}

.toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
  display: inline-block;
}

.toggle-icon.open {
  transform: rotate(90deg);
}

.exclude-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

.exclude-checkbox input {
  margin: 0;
  cursor: pointer;
}

.context-section-content {
  padding: var(--spacing-sm);
  background: var(--paper);
  border-top: 1px solid var(--border-color);
}

.context-section-content pre {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  color: var(--text-secondary);
  max-height: 150px;
  overflow-y: auto;
}

/* Copy success feedback */
.btn-copy-success {
  background: var(--signal-green) !important;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn-primary {
    border: 2px solid var(--text-primary);
  }

  .form-group input {
    border-width: 2px;
  }
}
