/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color palette */
    --primary-gradient-start: #667eea;
    --primary-gradient-end: #764ba2;
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --secondary-dark: #653a8f;

    /* Neutral colors */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-light: #e6e8f0;
    --border-medium: #cbd5e0;
    --bg-white: #ffffff;
    --bg-light: #f7fafc;
    --bg-lighter: #fbfbff;
    --bg-card: #ffffff;

    /* Status colors */
    --success-bg: #d4edda;
    --success-text: #155724;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --info-bg: #cce5ff;
    --info-text: #004085;

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 48px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.2);

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    min-height: 100vh;
    padding: var(--space-xl);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: var(--space-lg) var(--space-2xl);
    box-shadow: var(--shadow-lg);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xl);
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25em;
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.06);
}

.site-title {
    font-size: 1.25em;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.95;
    margin: 2px 0 0 0;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-links a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Keep the rest of nav/link rules compatible */
nav { margin-top: 0; }

/* Main content */
main {
    padding: var(--space-3xl) var(--space-2xl);
}

/* Upload section */
.upload-section {
    background: var(--bg-light);
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-2xl);
    box-shadow: var(--shadow-sm);
}

.upload-section h2 {
    margin-bottom: var(--space-xl);
    color: var(--primary-color);
    font-weight: 700;
}

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--border-light);
}

.tab-button {
    padding: var(--space-md) var(--space-xl);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: -2px;
    font-weight: 500;
}

.tab-button:hover {
    color: var(--primary-color);
    background: var(--bg-lighter);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 700;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* File input */
.file-input-wrapper {
    position: relative;
    margin-bottom: var(--space-xl);
}

/* URL input */
.url-input-wrapper {
    margin-bottom: var(--space-xl);
}

.url-input-wrapper input[type="url"],
.url-input-wrapper input[type="text"],
.url-input-wrapper input[type="range"] {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 1em;
    font-family: var(--font-sans);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-white);
}

.url-input-wrapper input[type="url"]:focus,
.url-input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.url-input-wrapper label {
    display: block;
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95em;
}

#urlPreview {
    margin-top: var(--space-xl);
}

#urlPreview img {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-md);
    border: 3px solid var(--primary-color);
    box-shadow: var(--shadow-md);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-input-wrapper label {
    display: inline-block;
    padding: var(--space-md) var(--space-2xl);
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.file-input-wrapper label:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#fileName {
    margin-left: var(--space-lg);
    color: var(--text-muted);
}

/* Drop zone styles */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    background: var(--surface);
    cursor: pointer;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.drop-zone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.drop-zone-icon {
    font-size: 3rem;
    line-height: 1;
}

.drop-zone-hover {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    background: rgba(102, 126, 234, 0.95);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.drop-zone-hover .drop-zone-icon {
    color: white;
}

.drop-zone.dragover .drop-zone-hover {
    display: flex;
}

.drop-zone.dragover .drop-zone-content {
    opacity: 0;
}

.drop-zone label {
    background: var(--primary-color);
    color: white;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.drop-zone label:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

#imagePreview {
    margin-top: var(--space-xl);
}

#imagePreview img {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-md);
    border: 3px solid var(--primary-color);
    box-shadow: var(--shadow-md);
}

button[type="submit"] {
    padding: var(--space-lg) var(--space-3xl);
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

button[type="submit"]:hover {
    background: var(--secondary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button[type="submit"]:active {
    transform: translateY(0);
}

/* Loading spinner */
#loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results */
.results-header {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border-light);
}

.results-header h2 {
    color: var(--primary-color);
    margin-bottom: var(--space-md);
    font-weight: 700;
}

.hash-info {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.hash-info code {
    background: var(--bg-light);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    color: var(--primary-color);
    font-size: 0.85em;
}

/* Result cards */
.result-card {
    background: var(--bg-white);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.result-header h3 {
    color: var(--text-primary);
    font-weight: 700;
}

.match-badge {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.85em;
    font-weight: 700;
    white-space: nowrap;
}

.match-badge.exact {
    background: var(--success-bg);
    color: var(--success-text);
}

.match-badge.near-exact {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.match-badge.similar {
    background: var(--info-bg);
    color: var(--info-text);
}

.result-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-xl);
}

.result-image {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.result-image img {
    width: 100%;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-light);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.info-section {
    padding: var(--space-lg);
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.info-section h4 {
    color: var(--primary-color);
    margin-bottom: var(--space-sm);
    font-size: 0.9em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-section p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.pricing-list {
    list-style: none;
    padding: 0;
}

.pricing-list li {
    padding: var(--space-xs) 0;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.source-link {
    display: inline-block;
    padding: var(--space-md) var(--space-xl);
    background: var(--primary-color);
    color: white !important;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.source-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Profiles table */
.profiles-list {
    margin-top: var(--space-2xl);
}

.profiles-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-xl);
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.profiles-table th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: var(--space-lg);
    text-align: left;
    font-weight: 700;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profiles-table td {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.profiles-table tr:hover {
    background: var(--bg-lighter);
}

.profiles-table tr:last-child td {
    border-bottom: none;
}

.btn-small {
    display: inline-block;
    padding: var(--space-sm) var(--space-lg);
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.btn-small:hover {
    background: var(--secondary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Profiles grid and cards */
.profiles-controls {
    margin-bottom: var(--space-lg);
}

.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

.profile-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.profile-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.card-top {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    width: 100%;
}

.profile-card .avatar {
    flex: 0 0 60%;
    height: 180px;
    min-height: 160px;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: 700;
    font-size: 2em;
    box-shadow: var(--shadow-sm);
}

.profile-card .avatar img,
.profile-card .avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.profile-card .card-info {
    flex: 1 1 40%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-sm);
}

.profile-card .card-title {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.card-title strong {
    color: var(--text-primary);
    font-size: 1.05em;
    line-height: 1.3;
}

.card-sub {
    color: var(--text-muted);
    font-size: 0.9em;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: 0.9em;
    color: var(--text-secondary);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.card-actions {
    margin-top: 0;
}

.copy-id {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    color: var(--primary-color);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: var(--space-sm);
    font-weight: 600;
}

.copy-id:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

@media (max-width: 768px) {
    .profiles-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .profile-card .avatar { flex: 0 0 50%; height: 140px; min-height: 120px; }
    .profile-card .card-info { flex: 1 1 50%; }
}

/* Error and status messages */
.error {
    padding: var(--space-lg) var(--space-xl);
    background: var(--error-bg);
    color: var(--error-text);
    border-radius: var(--radius-md);
    border: 1px solid #f5c6cb;
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
}

.no-results h3 {
    color: var(--primary-color);
    margin-bottom: var(--space-md);
    font-size: 1.3em;
}

.no-results p {
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* Footer */
footer {
    background: var(--bg-light);
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    font-size: 0.9em;
}

footer p {
    margin: 0;
}

/* App scaling wrapper for responsive zoom */
.scale-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 20px;
    --app-scale: 1;
}

/* Apply scale to the container via CSS variable set by JS */
.scale-wrapper > .container {
    transform: scale(var(--app-scale));
    transform-origin: top center;
    transition: transform 160ms ease;
    /* Ensure the scaled element doesn't cause horizontal scroll */
    width: calc(1200px);
}

/* Prevent horizontal overflow when scaling */
html, body {
    overflow-x: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: var(--space-md);
    }

    .container {
        border-radius: var(--radius-lg);
    }

    header {
        padding: var(--space-md) var(--space-lg);
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .nav-links {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .site-title {
        font-size: 1.1em;
    }

    main {
        padding: var(--space-xl) var(--space-lg);
    }

    .upload-section {
        padding: var(--space-lg);
    }

    .result-body {
        grid-template-columns: 1fr;
    }

    .profiles-grid {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .profile-card .avatar {
        flex: 0 0 40%;
        height: 120px;
    }
}

@media (max-width: 480px) {
    /* Container and header adjustments for small screens */
    body {
        padding: var(--space-sm);
    }

    .container {
        border-radius: var(--radius-md);
    }

    header {
        padding: var(--space-md);
    }

    .header-inner {
        align-items: center;
        gap: var(--space-sm);
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .site-title {
        font-size: 1em;
    }

    /* Make navigation wrap and increase hit area */
    .nav-links {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: var(--space-xs);
    }

    .nav-links a {
        padding: var(--space-md);
        font-size: 0.95em;
    }

    main {
        padding: var(--space-lg);
    }

    .upload-section {
        padding: var(--space-lg);
    }

    /* Tabs horizontal scrolling for very small screens */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: var(--space-sm);
        padding-bottom: var(--space-sm);
    }

    .tab-button {
        padding: var(--space-md);
        white-space: nowrap;
        font-size: 0.95em;
    }

    /* Make inputs and buttons full width for easier tapping */
    .file-input-wrapper label,
    button[type="submit"],
    .source-link,
    .btn-small {
        display: block;
        width: 100%;
        padding: var(--space-md) var(--space-lg);
        text-align: center;
        font-size: 1rem;
    }

    .url-input-wrapper input[type="url"],
    .url-input-wrapper input[type="text"] {
        font-size: 1rem;
        padding: var(--space-md);
    }

    /* Ensure previews scale correctly */
    #urlPreview img,
    #imagePreview img,
    .result-image img {
        max-width: 100%;
        height: auto;
        border-radius: var(--radius-md);
    }

    /* Compact result cards and stack layout */
    .result-card {
        padding: var(--space-lg);
        border-radius: var(--radius-md);
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .result-body {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .result-image {
        max-width: 100%;
    }

    .result-info {
        gap: var(--space-md);
    }

    /* Profiles table readable on small screens */
    .profiles-table th,
    .profiles-table td {
        padding: var(--space-md);
        font-size: 0.9rem;
    }

    .profiles-grid {
        grid-template-columns: 1fr;
    }

    .profile-card .avatar {
        flex: 0 0 35%;
        height: 100px;
        min-height: 90px;
    }

    .card-title strong {
        font-size: 0.95em;
    }

    /* Reduce spinner size on small screens */
    .spinner {
        width: 40px;
        height: 40px;
    }

    /* Footer spacing */
    footer {
        padding: var(--space-lg);
        font-size: 0.85em;
    }
}

/* Mark Inactive Button */
.mark-inactive-btn {
    padding: 6px 12px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mark-inactive-btn:hover {
    background: #f57c00;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mark-inactive-btn:active {
    transform: translateY(0);
}
