/* Global box-sizing for all elements */
* {
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Sans Mono', monospace;
  background-color: #fcfcfc;
  margin: 0;
  padding: 20px;
}

.container {
  max-width: 1400px; /* Increased from 1200px */
  margin: auto;
  background: #fff;
  padding: 20px;
  border: 2px dotted #000;
  border-radius: 0;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  font-weight: 700;
}

.retro-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 24px;
}

form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

input[type="url"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  font-family: inherit;
  box-sizing: border-box; /* Ensure padding is included in width */
}

button,
.btn {
  padding: 8px 16px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
}

button:hover,
.btn:hover {
  background: #000;
  color: #fff;
}

.btn-copy {
  background: #fff;
  color: #000;
}

.btn-download {
  background: #fff;
  color: #000;
}

.btn-clear {
  font-size:10px;
  padding:2px 6px;
}

/* spacing between inline buttons */
.btn + .btn {
  margin-left: 6px;
}

/* Table container to enable horizontal scroll on mobile */
.table-wrapper {
  overflow-x: auto;
}

.loading {
  text-align: left !important;
  font-weight: bold;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px dotted #000;
}

th, td {
  padding: 8px;
  border: 1px dotted #000;
  text-align: center;
  font-size: 12px;
}

th {
  background-color: #e8e8e8;
}

th[data-sort] {
  user-select: none;
}

th[data-sort]:hover {
  background-color: #d0d0d0;
}

/* Alt text column styling */
td:nth-child(3) {
  max-width: 200px;
  word-wrap: break-word;
  white-space: normal;
  text-align: left;
  padding-left: 10px;
  padding-right: 10px;
}

/* Center the dash when there's no alt text */
td.no-alt {
  text-align: center;
}

/* Adjust preview border */
.preview-container {
  border: 1px dotted #000;
}

/* Preview container with zoom icon */
.preview-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  overflow: visible;
  background-image: repeating-linear-gradient(45deg, #f7f7f7 0 10px, #ffffff 0 20px);
  margin:0 auto;
}

.preview-container img,
.preview-container object {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.zoom-icon {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  cursor: pointer;
}

.click-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* History list */
#history-container {
  margin-top: 20px;
}

#history {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 10px;
}

#history li {
  margin-bottom: 4px;
  font-size: 12px;
}

#history a {
  color: #007bff;
  text-decoration: none;
  border: 1px solid #ced4da;
  border-radius: 0;
  padding: 4px 6px;
  background: #f8f9fa;
  font-size: 12px;
  display:inline-flex;
  align-items:center;
  gap:4px;
}

#history a:hover {
  background: #e2e6ea;
}

.remove-link {
  cursor:pointer;
  color:red;
  font-weight:bold;
}

body.dark .remove-link {
  color:#f55;
}

.error-link {
  color: red !important;
  border-color: red !important;
}

.message {
  margin-top: 10px;
  color: red;
  white-space: pre-line;
  line-height: 1.5;
  font-size: 12px;
  text-align: left;
}

.message.error {
  font-weight: bold;
}

.footer {
  text-align: center;
  margin-top: 40px;
  font-size: 12px;
  color: #555;
}

body.dark .footer {
  color: #888;
}

/* Reusable button styles */
/* squared buttons override already in .btn above */

/* spacing between inline buttons */
.btn + .btn {
  margin-left: 6px;
}

/* Table container to enable horizontal scroll on mobile */
.table-wrapper {
  overflow-x: auto;
}

img, object {
  max-width: 100%;
  height: auto;
}

.toggle-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10;
  border-style: dotted;
}

/* Dark mode styles */
body.dark {
  background-color: #000;
  color: #e6e6e6;
}

body.dark .container {
  background: #000;
  border-color: #e6e6e6;
}

body.dark button,
body.dark .btn {
  background: #000;
  color: #e6e6e6;
  border-color: #e6e6e6;
}

body.dark button:hover,
body.dark .btn:hover {
  background: #e6e6e6;
  color: #000;
}

body.dark .toggle-btn {
  border-style: dotted;
  border-color: #e6e6e6;
}

body.dark table {
  border-color: #e6e6e6;
}

body.dark th, body.dark td {
  border-color: #e6e6e6;
  color: #e6e6e6;
}

body.dark th {
  background-color: #111;
}

body.dark .preview-container {
  border-color: #e6e6e6;
  background-image: repeating-linear-gradient(45deg, #2a2a2a 0 10px, #000 0 20px);
}

body.dark .zoom-icon {
  background: #000;
  color: #e6e6e6;
  border-color: #e6e6e6;
}

body.dark #history a {
  background: #111;
  color: #0f0;
  border-color: #0f0;
  border-radius: 0;
}

body.dark #history a:hover {
  background: #0f0;
  color: #000;
}

body.dark .error-link {
  color: #f55 !important;
  border-color: #f55 !important;
}

body.dark .message {
  color: #f55;
  white-space: pre-line;
  font-size: 12px;
  text-align: left;
}

.summary {
  margin:8px 0;
  font-size:12px;
  font-weight:bold;
}

body.dark .summary {color:#e6e6e6;}

.summary-bar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin:8px 0;
}

body.dark .summary-bar {color:#e6e6e6;}

/* Retro checkbox */
.inline-toggle-label input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px dotted #000;
  background: #fff;
  cursor: pointer;
  margin-right:4px;
}

.inline-toggle-label input[type="checkbox"]:checked {
  background: #000;
}

body.dark .inline-toggle-label input[type="checkbox"] {
  background: #000;
  border-color: #e6e6e6;
}

body.dark .inline-toggle-label input[type="checkbox"]:checked {
  background: #e6e6e6;
}

body.dark input[type="url"] {
  background:#000;
  color:#e6e6e6;
  border-color:#e6e6e6;
}

body.dark input[type="url"]::placeholder {
  color:#888;
}

.search-input {
  border-radius:0;
  color: #000;
  border: 1px solid #000;
  background: #fff;
}

body.dark .search-input {
  background:#111;
  color:#e6e6e6;
  border: 1px solid #e6e6e6;
}

/* Override inline styles for search input */
#search-input {
  border: 1px solid #000 !important;
}

body.dark #search-input {
  background: #111 !important;
  border: 1px solid #e6e6e6 !important;
  color: #e6e6e6 !important;
}

.tagline {
  text-align:center;
  font-size:12px;
  margin-top:-10px;
  margin-bottom:20px;
}

body.dark .tagline {color:#e6e6e6;}

/* Disabled button state */
button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f0f0f0;
  color: #999;
}

button:disabled:hover,
.btn:disabled:hover {
  background: #f0f0f0;
  color: #999;
}

body.dark button:disabled,
body.dark .btn:disabled {
  background: #222;
  color: #666;
}

body.dark button:disabled:hover,
body.dark .btn:disabled:hover {
  background: #222;
  color: #666;
}

@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  
  .container {
    padding: 15px;
    border-width: 1px;
  }
  
  /* Adjust title for mobile */
  .retro-title {
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  /* Tagline adjustments */
  .tagline {
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 15px;
  }
  
  /* Form styling */
  form {
    flex-direction: column;
    gap: 8px;
    width: 100%; /* Ensure form doesn't exceed container */
  }
  
  input[type="url"] {
    width: 100%;
    max-width: 100%; /* Prevent extending beyond container */
    font-size: 14px;
    padding: 6px 10px; /* Reduced padding for mobile */
    height: auto;
    box-sizing: border-box;
  }
  
  /* All buttons should have consistent mobile sizing */
  button,
  .btn {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 36px; /* Touch-friendly minimum height */
  }
  
  /* Form submit button - specific overrides */
  button[type="submit"] {
    width: 100%;
    font-size: 14px;
    padding: 8px 12px;
    min-height: 40px; /* Slightly larger for primary action */
  }
  
  /* Small utility buttons */
  .btn-clear {
    font-size: 10px;
    padding: 3px 6px;
    min-height: auto;
  }
  
  /* Action buttons in table */
  .btn-copy,
  .btn-download {
    padding: 4px 6px;
    font-size: 10px;
    min-height: auto;
  }
  
  /* Button spacing on mobile */
  .btn + .btn {
    margin-left: 3px;
  }
  
  /* History section */
  #history-container h3 {
    font-size: 14px;
  }
  
  #history {
    gap: 4px;
  }
  
  #history a {
    font-size: 11px;
    padding: 3px 5px;
  }
  
  /* Summary bar responsive layout */
  .summary-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .summary-search {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  
  .search-controls {
    width: 100%;
    display: flex;
    gap: 4px;
  }
  
  #search-input {
    flex: 1;
    width: auto !important;
    font-size: 12px !important;
    padding: 4px 6px !important; /* Smaller padding for mobile */
    height: auto;
  }
  
  body.dark #search-input {
    background: #111 !important;
    border: 1px solid #e6e6e6 !important;
  }
  
  #inline-toggle-label {
    margin-left: 0 !important;
    justify-content: center;
  }
  
  /* Table improvements - prevent smushing */
  .table-wrapper {
    margin: 0 -15px;
    width: calc(100% + 30px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  
  /* Add scroll indicator shadow */
  .table-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
  }
  
  body.dark .table-wrapper::after {
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.8));
  }

  table {
    font-size: 11px;
    min-width: 700px; /* Increased from 600px to accommodate alt text column */
    width: 100%;
  }
  
  th, td {
    padding: 5px 3px;
    font-size: 11px;
    white-space: nowrap; /* Prevent text wrapping in cells */
  }
  
  /* File name column can wrap */
  td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
    max-width: 120px;
  }
  
  /* Alt text column can also wrap on mobile */
  td:nth-child(3) {
    white-space: normal;
    word-break: break-word;
    max-width: 100px;
  }
  
  /* Smaller preview images on mobile */
  .preview-container {
    width: 50px;
    height: 50px;
  }
  
  .zoom-icon {
    width: 16px;
    height: 16px;
    font-size: 10px;
  }
  
  /* Theme toggle positioning */
  .toggle-btn {
    top: 5px;
    right: 5px;
    padding: 6px 10px;
    font-size: 14px;
  }
  
  /* Message box */
  .message {
    font-size: 11px;
    padding: 8px;
  }
  
  /* Footer */
  .footer {
    margin-top: 20px;
    font-size: 10px;
  }
  
  /* Hide tooltips on mobile (touch devices don't have hover) */
  .btn[data-tooltip]:hover::after,
  .zoom-icon[data-tooltip]:hover::after,
  .preview-container[data-tooltip]:hover::after,
  .click-layer[data-tooltip]:hover::after {
    display: none;
  }
}

/* Tablet/medium screens */
@media (min-width: 601px) and (max-width: 900px) {
  .container {
    padding: 20px;
  }
  
  .retro-title {
    font-size: 20px;
  }
  
  .preview-container {
    width: 60px;
    height: 60px;
  }
  
  .summary-bar {
    flex-wrap: wrap;
  }
}

/* Small landscape phones */
@media (max-width: 600px) and (orientation: landscape) {
  body {
    padding: 5px;
  }
  
  .container {
    padding: 10px;
  }
  
  .retro-title {
    font-size: 16px;
    margin-bottom: 10px;
  }
  
  .tagline {
    margin-bottom: 10px;
  }
}

.summary-search {
  display:flex;
  align-items:center;
  gap:8px;
}

.search-controls {
  display:flex;
  align-items:center;
  gap:4px;
} 

/* Instant tooltips using data-tooltip attribute */
.btn[data-tooltip],
.preview-container[data-tooltip],
.click-layer[data-tooltip] {
  position: relative;
}

.btn[data-tooltip]:hover::after,
.zoom-icon[data-tooltip]:hover::after,
.preview-container[data-tooltip]:hover::after,
.click-layer[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 3px 6px;
  font-size: 10px;
  white-space: nowrap;
  border: 1px solid #fff;
  z-index: 20;
  pointer-events: none;
}

body.dark .btn[data-tooltip]:hover::after,
body.dark .zoom-icon[data-tooltip]:hover::after,
body.dark .preview-container[data-tooltip]:hover::after,
body.dark .click-layer[data-tooltip]:hover::after {
  background: #e6e6e6;
  color: #000;
  border-color: #000;
}

/* Add spacing for zoom-icon tooltip */
.zoom-icon[data-tooltip]:hover::after {
  margin-bottom: 3px;
} 

/* SEO Metadata Drawer Styles */
.seo-drawer {
  margin: 20px 0;
  border: 1px dotted #000;
  background: #f8f9fa;
  overflow: hidden;
  /* Performance optimization */
  transform: translateZ(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #e8e8e8;
  border-bottom: 1px dotted #000;
  cursor: pointer;
}

.drawer-title {
  font-weight: bold;
  font-size: 14px;
}

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy-drawer {
  font-size: 11px;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid #000;
  cursor: pointer;
}

.btn-copy-drawer:hover {
  background: #000;
  color: #fff;
}

.drawer-toggle {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 0 5px;
  transition: transform 0.3s ease;
}

.drawer-toggle:hover {
  background: none;
}

.drawer-content {
  height: 200px;
  padding: 0;
  /* Removed transition to prevent choppiness */
  background: #fff;
  position: relative;
  resize: vertical;
  min-height: 50px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Performance optimizations */
  will-change: height, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  transform-origin: top;
}

/* Disable transition during resize for smoother performance */
.drawer-content:active {
  /* No transition needed */
}

.drawer-content.collapsed {
  height: 0 !important;
  min-height: 0;
  padding: 0;
  resize: none;
  overflow: hidden;
  visibility: hidden;
}

.drawer-toggle.collapsed {
  transform: rotate(-90deg);
}

.drawer-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 10px;
  padding-bottom: 20px;
  position: relative;
  /* Force horizontal scrollbar to always show when needed */
  overflow-x: scroll;
  /* Performance optimizations */
  will-change: scroll-position;
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
  /* Prevent layout thrashing */
  contain: layout;
  /* Smooth scrolling */
  scroll-behavior: smooth;
}

/* Ensure horizontal scrollbar is always visible */
.drawer-scroll-container::-webkit-scrollbar:horizontal {
  display: block !important;
}

/* Custom scrollbar styling for drawer */
.drawer-scroll-container::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

.drawer-scroll-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border: 1px solid #ccc;
}

.drawer-scroll-container::-webkit-scrollbar-thumb {
  background: #888;
  border: 1px solid #666;
  border-radius: 2px;
}

.drawer-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

body.dark .drawer-scroll-container::-webkit-scrollbar-track {
  background: #222;
  border-color: #444;
}

body.dark .drawer-scroll-container::-webkit-scrollbar-thumb {
  background: #666;
  border-color: #888;
}

body.dark .drawer-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #888;
}

#head-content {
  margin: 0;
  font-family: 'IBM Plex Sans Mono', monospace;
  font-size: 12px;
  white-space: pre;
  word-wrap: normal;
  background: transparent;
  overflow: visible;
  counter-reset: line;
  line-height: 1.4;
  display: inline-block;
  min-width: max-content;
  /* Performance optimization - removed to prevent issues */
}

/* Line numbers */
.code-line {
  display: inline-block;
  position: relative;
  padding-left: 40px;
  line-height: 1.4;
  width: 100%;
  min-height: 1.4em;
  /* Performance optimization - use paint containment only */
  contain: paint;
}

.code-line::before {
  content: counter(line);
  counter-increment: line;
  position: absolute;
  left: 0;
  width: 30px;
  text-align: right;
  color: #666;
  font-size: 11px;
  user-select: none;
  line-height: 1.4;
}

/* Resize handle styling */
.drawer-content::after {
  content: '⋮⋮';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  cursor: ns-resize;
  z-index: 10;
  font-size: 10px;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(90deg);
  user-select: none;
  pointer-events: auto;
}

/* Larger invisible resize area for easier grabbing */
.drawer-content::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 10px;
  cursor: ns-resize;
  z-index: 9;
}

/* Override browser's default resize handle */
.drawer-content::-webkit-resizer {
  background: transparent;
}

body.dark .drawer-content::after {
  color: #666;
}

/* Syntax highlighting - Retro themed */
.tag-bracket { color: #000; font-weight: bold; }
.tag-name { color: #00f; font-weight: bold; }
.attribute { color: #008000; }
.attribute-value { color: #800080; }
.comment { color: #666; font-style: italic; }
.doctype { color: #800; font-weight: bold; }

/* Dark mode styles for SEO drawer */
body.dark .seo-drawer {
  background: #111;
  border: 1px dotted #e6e6e6;
}

body.dark .drawer-header {
  background: #222;
  border-bottom-color: #e6e6e6;
  color: #e6e6e6;
}

body.dark .drawer-controls {
  color: #e6e6e6;
}

body.dark .btn-copy-drawer {
  background: #000;
  color: #e6e6e6;
  border: 1px solid #e6e6e6;
}

body.dark .btn-copy-drawer:hover {
  background: #e6e6e6;
  color: #000;
}

body.dark .drawer-toggle {
  color: #e6e6e6;
}

body.dark .drawer-content {
  background: #000;
}

body.dark #head-content {
  color: #e6e6e6;
}

body.dark .code-line::before {
  color: #888;
}

/* Dark mode syntax highlighting */
body.dark .tag-bracket { color: #e6e6e6; }
body.dark .tag-name { color: #0f0; }
body.dark .attribute { color: #f0f; }
body.dark .attribute-value { color: #ff0; }
body.dark .comment { color: #999; }
body.dark .doctype { color: #f55; }

/* Mobile styles for SEO drawer */
@media (max-width: 600px) {
  .seo-drawer {
    margin: 15px 0;
    border: 1px dotted #000;
  }
  
  body.dark .seo-drawer {
    border: 1px dotted #e6e6e6;
  }
  
  .drawer-header {
    padding: 8px;
  }
  
  .drawer-title {
    font-size: 12px;
  }
  
  .drawer-content {
    height: 150px;
    max-height: 50vh;
    resize: none; /* Disable resize on mobile */
  }
  
  .drawer-scroll-container {
    padding: 8px;
    padding-bottom: 8px;
  }
  
  .drawer-content::after {
    display: none; /* Hide resize handle on mobile */
  }
  
  .btn-copy-drawer {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .code-line {
    padding-left: 35px;
  }
  
  .code-line::before {
    width: 25px;
    font-size: 10px;
  }
} 