/**
 * @file style.css
 * @description Stylesheet for Infra-Mapper.
 * @version 5.37.00
 */

:root {
    --text: #0d1117;
    --muted: #57606a;
    --border: #d0d7de;
    --bg: #f6f8fa;
    --bg-alt: #ffffff;
    --bg-header: #f1f5f9;
    --bg-secondary: #f1f5f9; /* Mapped for export group select */
    --bg-pre: #f7f8fa;
    --border-pre: #d0d7de;
    --button-copy-bg: #eef1f6;
    --link-color: #0969da;
    --error-color: #d32f2f;
    --primary-color: #0066cc;
    --bg-card: #ffffff;
    --text-muted: #666;
    
    /* Mobile-First Variables */
    --spacing-unit: 10px;
    --touch-target: 48px;
}

html.dark-mode {
    --text: #e6edf3;
    --muted: #8b949e;
    --border: #30363d;
    --bg: #0d1117;
    --bg-alt: #161b22;
    --bg-header: #1c2128;
    --bg-secondary: #1c2128;
    --bg-pre: #1a1f27;
    --border-pre: #3b424c;
    --button-copy-bg: #2d333b;
    --link-color: #58a6ff;
    --error-color: #ef5350;
    --primary-color: #4da3ff;
    --bg-card: #1e1e1e;
    --text-muted: #aaa;
}

/* Global Reset & Box Sizing */
*, *:before, *:after {
    box-sizing: border-box;
}

html, body {
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    overflow-x: auto;
}

body {
    margin: 18px;
    padding-bottom: 60px; /* Space for footer */
    color: var(--text);
    background-color: var(--bg);
    font-family: Inter, system-ui, Arial, sans-serif;
    font-size: 14px;
    position: relative;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Form Elements */
input,
button,
textarea,
select {
    background-color: var(--bg-alt);
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
}

textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

/* Specific Input Styling from Mobile Overrides */
textarea#domains {
    width: 100%;
    max-width: 100%;
    min-height: 160px;
    padding: 12px;
    font-family: monospace;
    font-size: 16px; 
    line-height: 1.4;
}

input[type="text"], input[type="password"], select {
    width: 100%;
    min-height: var(--touch-target);
    padding: 8px;
    font-size: 16px;
}

/* Base button style */
button {
    background: #0969da;
    color: #fff;
    border: 0;
    margin-left: 6px;
    cursor: pointer;
}

button[disabled],
input[disabled],
select[disabled],
textarea[disabled] {
    opacity: .6;
    cursor: default;
}

/* Grid System */
.grid-container {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 15px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: 1fr 1fr; 
    }
}

.full-width {
    grid-column: 1 / -1;
}

/* Rows & Flex Layouts */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    align-items: stretch;
}

.row .btn-action {
    flex: 1 1 0; 
    min-width: 90px; 
    min-height: var(--touch-target);
    white-space: nowrap;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    /* Reapplying button defaults as class might override generic button */
    background: #0969da;
    color: #fff;
    border: 0;
    cursor: pointer;
}

.scan-row-flex {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    justify-content: space-between;
}

.scan-row-flex label {
    flex: 1 1 auto;
    min-width: 150px;
    white-space: normal;
}

/* Export Group Styling */
.export-group {
    display: flex;
    flex: 1 1 100%;
    min-width: 250px;
}

.export-group button {
    flex: 1 1 auto;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.export-group select {
    flex: 0 0 90px; 
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background-color: var(--bg-secondary);
    text-align: center;
}

/* Text & Utils */
.muted {
    color: var(--muted);
}

pre, code {
    white-space: pre-wrap;
    word-break: break-all;
}

pre {
    background: var(--bg-pre);
    border: 1px solid var(--border-pre);
    padding: 10px;
    border-radius: 8px;
    max-height: 45vh;
    overflow: auto;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Details & Summary */
details {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: var(--bg-alt);
    margin: 10px 0;
    position: relative;
    z-index: 1;
    overflow-x: auto; 
}

details details {
    margin-left: 15px;
    margin-top: 8px;
    margin-bottom: 8px;
}

summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

details > summary {
    display: flex;
    align-items: center;
}

summary::before {
    content: '▶';
    color: var(--muted);
    font-size: 0.8em;
    margin-right: 8px;
    display: inline-block;
    transition: transform 0.2s ease-in-out;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

.kv {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
    background: var(--bg-alt);
    margin: 2px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    table-layout: auto; 
}

th, td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    word-break: break-word; 
    overflow-wrap: anywhere;
}

th {
    background: var(--bg-header);
}

/* Source Row Styling (Mobile Redesign) */
tr.source-row td {
    background-color: #f4f4f4; /* Light gray for separation */
    color: #555;
    font-size: 0.85em;
    font-weight: bold;
    padding: 4px 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #ddd;
}

tr.data-row td {
    padding-top: 8px;
    padding-bottom: 12px;
}

/* Dark Mode Overrides for Tables */
.dark-mode tr.source-row td {
    background-color: #2a2a2a;
    color: #aaa;
    border-bottom: 1px solid #444;
}

/* Utilities */
.action-icon {
    cursor: pointer;
    margin-left: 5px;
    text-decoration: none;
    font-size: 1.2em; 
    opacity: 0.7;
    vertical-align: middle;
    padding: 6px; 
    display: inline-block;
}
.action-icon:hover {
    opacity: 1;
}

.nowrap-container {
    white-space: nowrap;
    display: inline-block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Info & Warning Boxes */
.info-box {
    background-color: #ddf4ff;
    border: 1px solid #58a6ff;
    padding: 10px;
    border-radius: 8px;
    margin: 12px 0;
    color: #0d1117;
}

html.dark-mode .info-box {
    background-color: #162233;
    color: #e6edf3;
}

.warning-box {
    background-color: #fff8c5;
    border: 1px solid #d29922;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    color: #0d1117;
}

html.dark-mode .warning-box {
    background-color: #2e2917;
    color: #e6edf3;
}

/* Progress Bar */
progress {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

progress::-webkit-progress-bar {
    background-color: var(--bg-pre);
}

progress::-webkit-progress-value {
    background-color: #0969da;
    border-radius: 6px;
}

.api-key-input {
    width: 100%;
}

#resultsContainer, #warnings {
    position: relative;
    z-index: 1;
}

#resultsContainer details summary {
    font-size: 1.1em;
    padding: 6px 0;
}

/* Theme Toggle */
#theme-toggle {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
}

#theme-toggle svg {
    width: 100%;
    height: 100%;
    fill: var(--muted);
}

#theme-toggle .sun-icon {
    display: none;
}

#theme-toggle .moon-icon {
    display: block;
}

html.dark-mode #theme-toggle .sun-icon {
    display: block;
}

html.dark-mode #theme-toggle .moon-icon {
    display: none;
}

/* History */
#historyContainer {
    margin-top: 12px;
}

#historyChips {
    max-height: 150px;
    overflow-y: auto;
    padding: 4px;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 6px;
    margin: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.history-chip:hover {
    background-color: var(--bg-pre);
}

.history-add-btn,
.history-delete-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    font-family: system-ui, sans-serif;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
}

.history-add-btn:hover,
.history-delete-btn:hover {
    color: var(--text);
    background-color: rgba(128, 128, 128, 0.2);
}

.history-add-btn {
    margin-right: 6px;
    font-weight: 600;
}

.history-delete-btn {
    margin-left: 6px;
}

/* Sticky Footer */
#sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0; /* Updated from width:100vw to ensure responsiveness */
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #ccc;
    padding: 10px;
    z-index: 2147483647;
    backdrop-filter: blur(5px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 25px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    font-size: 0.8em;
    line-height: 1.4;
    color: var(--text-muted);
}

.dark-mode #sticky-footer {
    background: rgba(30, 30, 30, 0.95);
    border-color: #444;
}

#sticky-footer a {
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

#sticky-footer a:hover {
    text-decoration: underline;
}

#sticky-footer span {
    white-space: nowrap;
}

/* File Upload */
.file-upload-label {
    display: inline-block;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    font-size: 14px;
    font-family: inherit;
    color: var(--muted);
    margin-left: 0;
}

/* Consent Modal */
#consent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

#consent-overlay.is-visible {
    display: flex;
}

#consent-modal {
    background-color: var(--bg-alt);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    max-width: 500px;
    text-align: left;
}

#consent-modal h3 {
    margin-top: 0;
}

#consent-modal p {
    line-height: 1.5;
}

#consent-buttons {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#consent-buttons button {
    margin-left: 0;
}

#decline-consent {
    background-color: var(--muted);
}

#consent-return-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    text-align: center;
    z-index: 150;
    font-size: 13px;
}

#consent-return-banner.is-visible {
    display: block;
}

/* Compact Display */
#resultsContainer.compact-display details {
    margin: 2px 0;
}

#resultsContainer.compact-display details details {
    margin-top: 2px;
    margin-bottom: 2px;
}

#resultsContainer.compact-display details summary {
    padding: 4px 0;
    font-size: 1em;
}

#resultsContainer.compact-display table {
    font-size: 13px;
}

#resultsContainer.compact-display th,
#resultsContainer.compact-display td {
    padding: 4px 8px;
}

/* Scan Options Layout Classes */
.scan-section {
    margin-bottom: 12px;
}

.scan-header {
    font-weight: bold;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.scan-subsection {
    margin-left: 12px !important;
    margin-bottom: 4px;
    border-left: 2px solid var(--border);
    padding-left: 8px;
    font-size: 0.9em;
}

.scan-label-small {
    font-size: 0.85em;
    margin-left: 8px;
}

.scan-section-bordered {
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

/* Utility classes */
.hidden { display: none !important; }

.is-disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: default;
}

.is-error {
    color: var(--error-color);
}

.spf-indented {
    margin-left: 20px;
}

.spf-mechanism-code {
    display: block;
    margin-bottom: 5px;
}

.ns-record-list {
    margin: 4px 0 10px 0;
}

.input-small-60 {
    flex: 0 0 60px;
    text-align: center;
    width: 60px;
    padding: 4px;
    font-size: 13px;
}

.input-small-30 {
    flex: 0 0 30px; /* Adapted flex properties */
    text-align: center;
    width: 30px;
    padding: 4px;
    font-size: 13px;
}

.input-small-select {
    padding: 4px;
    font-size: 13px;
}

.margin-bottom-2 { margin-bottom: 2px; }
.margin-bottom-4 { margin-bottom: 4px; }
.margin-bottom-5 { margin-bottom: 5px !important; }
.margin-top-5 { margin-top: 5px !important; }
.margin-top-8 { margin-top: 8px; }
.margin-12-0 { margin: 12px 0; }
.margin-5-0 { margin: 5px 0 !important; }
.margin-left-0 { margin-left: 0 !important; }
.muted-text-block { margin-bottom: 8px; }

.log-header-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.log-header-row-top {
    display: flex;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 4px;
}

.log-buttons-group {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.cache-indicator {
    font-weight: normal;
    font-size: 0.9em;
}

.break-all {
    word-break: break-all;
}

.clipboard-helper {
    position: fixed;
    top: 0;
    left: 0;
    width: 2em;
    height: 2em;
    padding: 0;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
}

/* Specific button colors overrides */
.file-upload-label, 
#runButton,
#copyLinkButton, 
#dlJson, 
#dlCsv, 
.copy-btn {
    background-color: #007bff !important;
    color: white !important;
    border: 1px solid transparent;
}

.file-upload-label:not(.is-disabled):hover, 
#runButton:not(:disabled):hover,
#copyLinkButton:not(:disabled):hover, 
#dlJson:not(:disabled):hover, 
#dlCsv:not(:disabled):hover, 
.copy-btn:not(:disabled):hover {
    background-color: #0056b3 !important;
    cursor: pointer;
}

.file-upload-label.is-disabled,
#runButton:disabled,
#copyLinkButton:disabled, 
#dlJson:disabled, 
#dlCsv:disabled, 
.copy-btn:disabled {
    background-color: #007bff !important; 
    opacity: 0.65 !important;            
    cursor: not-allowed !important;
}

/* Link Action Spacing */
.link-action-row { 
    margin-top: 8px; 
}

/* Scan Options Container */
#scanOptionsContainer { 
    min-width: 460px !important; 
}
#scanOptionsContainer label { 
    white-space: nowrap; 
}

#status {
    min-height: 2.8em;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}