/**
 * PatPDFs WordPress Plugin - Application Styles
 * 
 * This stylesheet contains only structural and functional CSS required for the plugin
 * to operate correctly. Visual styling (colors, typography, spacing) should be inherited
 * from the WordPress theme where possible.
 * 
 * Copyright (c) 2025 Brown Dog Software LLC. All Rights Reserved.
 * 
 * NOTICE: All information contained herein is, and remains the property of
 * Brown Dog Software LLC. The intellectual and technical concepts contained herein are
 * proprietary to Brown Dog Software LLC and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material is strictly
 * forbidden unless prior written permission is obtained from Brown Dog Software LLC.
 * 
 * Unauthorized copying of this file, via any medium, is strictly prohibited.
 */

/* Scoped container - ensures box-sizing doesn't conflict with theme */
.patpdfs-app *,
.patpdfs-app *::before,
.patpdfs-app *::after {
  box-sizing: border-box;
}

.patpdfs-app {
  position: relative;
}

/* Fatal error display - shown when app fails to initialize */
.patpdfs-fatal-error {
  padding: 1.5rem;
  margin: 1rem 0;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
}

.patpdfs-fatal-error h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: inherit;
}

.patpdfs-fatal-error p {
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.patpdfs-fatal-error details {
  margin-top: 1rem;
}

.patpdfs-fatal-error summary {
  cursor: pointer;
  font-weight: 500;
}

.patpdfs-fatal-error pre {
  margin: 0.5rem 0 0 0;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace;
}

.patpdfs-app .patpdfs-browser-warning {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  background: #fff7ed;
  color: inherit;
  line-height: 1.4;
}

/* Fieldset styling - themes often don't provide this for front-end */
.patpdfs-app fieldset {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.patpdfs-app legend {
  padding: 0 0.5rem;
  font-weight: 600;
}

.patpdfs-app .options-fieldset {
  position: relative;
  padding-top: 0.75rem;
}

.patpdfs-app .options-fieldset legend {
  margin-bottom: 0.25rem;
  padding: 0;
}

.patpdfs-app .options-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.patpdfs-app .options-toggle:focus,
.patpdfs-app .options-toggle:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

.patpdfs-app .options-toggle::after {
  content: '';
  border-style: solid;
  border-width: 0.35rem 0.35rem 0 0.35rem;
  border-color: currentColor transparent transparent transparent;
  transition: transform 0.15s ease;
}

.patpdfs-app .options-fieldset[aria-expanded='true'] .options-toggle::after {
  transform: rotate(180deg);
}

.patpdfs-app .options-content {
  margin-top: 0.5rem;
}

.patpdfs-app .options-content[hidden] {
  display: none !important;
}

.patpdfs-app .option-credit {
  margin-top: 0.75rem;
  text-align: right;
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.85;
}

/* Form element sizing - structural only, theme handles cosmetics */
.patpdfs-app textarea {
  width: 100%;
  min-height: 8rem;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: auto;
  resize: vertical;
}

.patpdfs-app input[type="text"],
.patpdfs-app input[type="number"],
.patpdfs-app select {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

@media (min-width: 640px) {
  .patpdfs-app input[type="text"],
  .patpdfs-app input[type="number"],
  .patpdfs-app select {
    width: 20rem;
    max-width: 100%;
  }
}

/* Monospace for technical content (IDs and logs) - functional requirement */
.patpdfs-app textarea#ids,
.patpdfs-app #log {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace;
}

.patpdfs-app textarea#ids {
  font-size: 1rem;
}

.patpdfs-app #log[hidden] {
  display: none !important;
}


.patpdfs-app .status-panel {
  overflow-x: auto;
  max-width: 100%;
}

.patpdfs-app .status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}


.patpdfs-app .status-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  font-size: 1rem;
  color: inherit;
}

.patpdfs-app .status-summary__spinner {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 2px solid rgba(10, 98, 215, 0.25);
  border-top-color: rgba(10, 98, 215, 0.85);
  animation: patpdfs-spin 0.75s linear infinite;
}

.patpdfs-app .status-summary__text {
  display: inline-block;
}

.patpdfs-app .status-toggle {
  min-width: 0;
  border-radius: 12px;
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: #f1f3f7;
  color: #6b7280;
  border: 2px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.patpdfs-app .status-toggle[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.patpdfs-app .status-toggle[hidden] {
  display: none !important;
}

.patpdfs-app .status-toggle:not([disabled]):hover,
.patpdfs-app .status-toggle:not([disabled]):focus-visible {
  background: #e6e9ef;
  color: #4b5563;
}

.patpdfs-app .status-toggle:not([disabled]):focus {
  background: #e6e9ef;
  color: #4b5563;
}

.patpdfs-app .status-toggle:focus,
.patpdfs-app .status-toggle:focus-visible {
  outline: none;
  border-color: #1a73e8;
}

.patpdfs-app .status-details {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.patpdfs-app .status-legend {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

.patpdfs-app .status-legend summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.patpdfs-app .status-legend summary::-webkit-details-marker {
  display: none;
}

.patpdfs-app .status-legend summary::after {
  content: '▸';
  display: inline-block;
  margin-left: 0.4rem;
  transition: transform 0.2s ease;
}

.patpdfs-app .status-legend[open] summary::after {
  transform: rotate(90deg);
}

.patpdfs-app .status-legend-content {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.patpdfs-app .status-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}

.patpdfs-app .status-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.patpdfs-app .status-legend-label {
  line-height: 1.2;
}

.patpdfs-app .status-legend-item .status-icon {
  width: 1.25rem;
  height: 1.25rem;
  border: none;
  background: none;
  padding: 0;
}


.patpdfs-app #statusTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 28rem;
}

.patpdfs-app #statusTable th,
.patpdfs-app #statusTable td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
  vertical-align: top;
  background: none;
}

.patpdfs-app #statusTable tbody tr:last-child td {
  border-bottom: none;
}

.patpdfs-app #statusTable th {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.patpdfs-app #statusTable td[data-role="query"],
.patpdfs-app #statusTable td[data-role="type"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace;
  font-size: 0.95rem;
  word-break: break-word;
}

.patpdfs-app #statusTable td[data-role="type"] {
  color: inherit;
  opacity: 0.9;
}

.patpdfs-app #statusTable td[data-role="status"] {
  min-width: 8rem;
}

.patpdfs-app #statusTable .status-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.patpdfs-app #statusTable .status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.375rem;
  background: #f5f5f5;
  border: 1px solid #e1e1e1;
  padding: 0.125rem;
  position: relative;
}

.patpdfs-app #statusTable .status-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.patpdfs-app #statusTable .status-icon[title] {
  cursor: help;
}

.patpdfs-app #statusTable tr.status-row--active td {
  background: #f5f9ff;
}

.patpdfs-app #statusTable .status-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 2px solid #aecbfa;
  border-top-color: #1a73e8;
  animation: patpdfs-status-spin 0.75s linear infinite;
  flex: 0 0 auto;
  margin-left: auto;
}

@keyframes patpdfs-status-spin {
  to {
    transform: rotate(360deg);
  }
}

@supports not (gap: 0.5rem) {
  .patpdfs-app .status-header > * {
    margin-right: 0.75rem;
    margin-bottom: 0.5rem;
  }
  .patpdfs-app .status-header > *:last-child {
    margin-right: 0;
  }

  .patpdfs-app .status-summary > * {
    margin-right: 0.65rem;
  }
  .patpdfs-app .status-summary > *:last-child {
    margin-right: 0;
  }

  .patpdfs-app .status-details > * {
    margin-bottom: 0.75rem;
  }
  .patpdfs-app .status-details > *:last-child {
    margin-bottom: 0;
  }

  .patpdfs-app .status-legend-content > * {
    margin-bottom: 0.5rem;
  }
  .patpdfs-app .status-legend-content > *:last-child {
    margin-bottom: 0;
  }

  .patpdfs-app .status-legend-row > * {
    margin-right: 1.25rem;
    margin-bottom: 0.5rem;
  }
  .patpdfs-app .status-legend-row > *:last-child {
    margin-right: 0;
  }

  .patpdfs-app .status-legend-item > * {
    margin-right: 0.5rem;
  }
  .patpdfs-app .status-legend-item > *:last-child {
    margin-right: 0;
  }

  .patpdfs-app #statusTable .status-icons > * {
    margin-right: 0.35rem;
  }
  .patpdfs-app #statusTable .status-icons > *:last-child {
    margin-right: 0;
  }
}


/* Loading spinner - functional animation */
.patpdfs-app .spinner {
  width: 22px;
  height: 22px;
  border: 3px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: patpdfs-spin 0.8s linear infinite;
  opacity: 0.6;
}

.patpdfs-app .spinner.hidden {
  display: none;
}

@keyframes patpdfs-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Layout utilities - functional flexbox */
.patpdfs-app .row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
}

.patpdfs-app .row > * {
  min-width: 0;
}

.patpdfs-app .row.actions {
  justify-content: center;
}

.patpdfs-app .row.actions + .row.actions {
  margin-top: 1rem;
}

.patpdfs-app #primaryActions {
  margin-bottom: 1.75rem;
  gap: 1rem;
  width: 100%;
}

/* Accessibility - screen reader only text */
.patpdfs-app .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* WordPress notice styling for alerts */
.patpdfs-app .notice {
  background: #fff;
  border-left: 4px solid #72aee6;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.patpdfs-app .notice-warning {
  border-left-color: #dba617;
  background: #fcf9e8;
}

.patpdfs-app .notice-error {
  border-left-color: #d63638;
  background: #fcf0f1;
}

.patpdfs-app .notice-success {
  border-left-color: #00a32a;
  background: #edfaef;
}

/* Need-review list styling */
.patpdfs-app .need-list {
  margin-top: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  background: #fafafa;
  max-height: 10rem;
  overflow: auto;
  text-align: left;
}

.patpdfs-app .need-list-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.patpdfs-app .need-list ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.patpdfs-app .need-list li {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace;
}

/* Hint with link layout */
.patpdfs-app .hint-with-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.patpdfs-app .hint-with-link .hint-link {
  margin-left: auto;
}

/* Modal overlay - functional positioning and layering */
.patpdfs-app .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.patpdfs-app .modal-overlay[hidden] {
  display: none !important;
}

.patpdfs-app .modal-content {
  background: var(--wp--preset--color--background, #fff);
  border-radius: 0.5rem;
  max-width: 40rem;
  width: min(100%, 40rem);
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.patpdfs-app .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.patpdfs-app .modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

/* Focus states - accessibility requirement */
.patpdfs-app .modal-close:focus-visible,
.patpdfs-app .link-btn:not([disabled]):not([aria-disabled="true"]):focus-visible,
.patpdfs-app .hint-link:focus-visible {
  outline: 2px solid;
  outline-offset: 2px;
}

/* Captcha overlay - functional positioning */
.patpdfs-app #captchaOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1100;
}

.patpdfs-app #captchaOverlay[hidden] {
  display: none !important;
}

.patpdfs-app #captchaBox {
  background: var(--wp--preset--color--background, #fff);
  border-radius: 0.5rem;
  width: min(100%, 22rem);
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.patpdfs-app #captchaActions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Button layout - WordPress handles most styling, we add structure */
.patpdfs-app .btn,
.patpdfs-app .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.patpdfs-app #primaryActions .btn {
  flex: 1 1 100%;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 14px;
  border: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.patpdfs-app #primaryActions .button-primary {
  background: #2f80ff;
  color: #fff;
  box-shadow: 0 12px 24px -16px rgba(47, 128, 255, 0.8);
}

.patpdfs-app #primaryActions .button-primary:hover,
.patpdfs-app #primaryActions .button-primary:focus-visible {
  background: #1f6ff5;
  box-shadow: 0 18px 28px -18px rgba(47, 128, 255, 0.9);
  color: #fff;
}

.patpdfs-app #primaryActions .button-primary:disabled,
.patpdfs-app #primaryActions .button-primary[aria-disabled="true"] {
  background: #a9c9ff;
  box-shadow: none;
  color: #fff;
}

.patpdfs-app #primaryActions .button-secondary {
  background: #f1f3f7;
  color: #6b7280;
  box-shadow: none;
}

.patpdfs-app #primaryActions .button-secondary:hover,
.patpdfs-app #primaryActions .button-secondary:focus-visible {
  background: #e6e9ef;
  color: #4b5563;
}

.patpdfs-app #primaryActions .button-secondary:disabled,
.patpdfs-app #primaryActions .button-secondary[aria-disabled="true"] {
  color: #bcc1c9;
  background: #f5f6f8;
}

@media (min-width: 640px) {
  .patpdfs-app #primaryActions .btn {
    flex: 0 0 auto;
    min-width: 11rem;
  }
}

/* Link-style buttons - WordPress link colors with our structure */
.patpdfs-app .link-btn,
.patpdfs-app .hint-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--wp--preset--color--link, inherit);
  text-decoration: underline;
}

.patpdfs-app .link-btn:hover,
.patpdfs-app .hint-link:hover {
  color: var(--wp--preset--color--link-hover, var(--wp--preset--color--link, inherit));
}

.patpdfs-app .link-btn[disabled],
.patpdfs-app .link-btn[aria-disabled="true"] {
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: none;
  outline: none;
  opacity: 0.5;
  color: #999;
}
