/* pr0clip - Main Stylesheet */

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #fff;
    line-height: 1.4;
}

/* Header */
.header {
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    padding: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    color: #ee4c2c;
    text-align: center;
    font-weight: 400;
}

/* Content area */
.content {
    padding: 8px;
    max-width: 1052px;
    margin: 0 auto;
}

/* Layout Components */
.container {
    max-width: none;
    margin: 0;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.container.small {
    max-width: 800px;
    margin: 0 auto;
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
}

/* Typography */
h1 {
    color: #fff;
    text-align: center;
    margin: 20px 0;
    font-size: 24px;
    font-weight: 300;
}

h2 {
    color: #fff;
    margin: 20px 8px 10px 8px;
    font-size: 18px;
    font-weight: 400;
}

h3 {
    color: #ccc;
    margin-bottom: 15px;
}

/* Navigation */
.navigation {
    text-align: center;
    margin-bottom: 30px;
}

.nav-link {
    display: inline-block;
    margin: 0 15px;
    padding: 10px 20px;
    background: #2a2a2a;
    color: #ddd;
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid #333;
    transition: all 0.2s ease;
}

.nav-link.active {
    background: #ee4c2c;
    color: #fff;
    border-color: #ee4c2c;
}

.nav-link:hover {
    background: #333;
    color: #fff;
    border-color: #444;
    text-decoration: none;
}

.nav-link.active:hover {
    background: #d54328;
}

/* Form Elements */
.upload-form, .search-form, .url-form {
    text-align: center;
}

.file-input, .url-input {
    margin: 20px 0;
    padding: 20px;
    border: 2px dashed #444;
    border-radius: 6px;
    background: #1f1f1f;
    color: #ddd;
}

.file-input:hover, .url-input:hover {
    border-color: #555;
}

/* OR separator */
.or-separator {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.or-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #444;
}

.or-separator span {
    background: #2a2a2a;
    padding: 0 20px;
    color: #999;
    font-size: 14px;
    position: relative;
    z-index: 1;
}

input[type="file"] {
    padding: 10px;
    font-size: 16px;
    background: #1f1f1f;
    color: #ddd;
    border: 1px solid #333;
    border-radius: 6px;
}

input[type="file"]::file-selector-button {
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 12px;
    margin-right: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
    background: #333;
    border-color: #555;
    color: #fff;
}

input[type="text"] {
    width: 100%;
    max-width: 500px;
    padding: 15px;
    font-size: 16px;
    background: #1f1f1f;
    color: #eee;
    border: 1px solid #333;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]::placeholder {
    color: #888;
}

input[type="text"]:focus {
    outline: none;
    border-color: #ee4c2c;
    box-shadow: 0 0 0 2px rgba(238, 76, 44, 0.15);
}

.submit-btn {
    background: #ee4c2c;
    color: #fff;
    padding: 12px 30px;
    border: 1px solid #ee4c2c;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
    background: #d54328;
    border-color: #d54328;
    box-shadow: 0 0 0 2px rgba(238, 76, 44, 0.15);
}

/* Content Sections */
.query-section {
    text-align: center;
    margin: 20px 8px;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #333;
}

.query-image {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.description {
    margin-top: 30px;
    padding: 20px;
    background: #232323;
    border-radius: 8px;
    border: 1px solid #333;
    color: #ccc;
}

.examples {
    margin: 30px 0;
    text-align: center;
}

.examples h3 {
    margin-bottom: 20px;
    color: #fff;
    text-align: center;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center;
}

.example-item {
    position: relative;
    display: block;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.15s ease;
    border: 1px solid #333;
}

.example-item:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.example-item img {
    width: 100%;
    height: auto;
    display: block;
    border: none;
    border-radius: 4px;
    transition: opacity 0.15s ease;
    object-fit: cover;
    background: #333;
    min-height: 120px;
    max-height: 160px;
}

.example-item .overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    border-radius: 4px;
}

.example-item:hover .overlay {
    opacity: 1;
    pointer-events: auto;
}

.example-item .actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.example-item .actions a {
    color: #fff;
    text-decoration: none;
    background: #ee4c2c;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.15s ease;
    text-align: center;
    min-width: 60px;
}

.example-item .actions a:hover {
    background: #d54328;
    text-decoration: none;
}

.example-item .actions .view-original {
    background: #444;
}

.example-item .actions .view-original:hover {
    background: #555;
}

/* Tags */
.tags, .query-tags {
    margin: 20px 0;
}

.tag, .query-tag {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 5px 12px;
    margin: 3px;
    border-radius: 15px;
    font-size: 14px;
}

.query-tag {
    background: #28a745;
    padding: 8px 15px;
    font-weight: bold;
}

/* Results Sections */
.results-section {
    margin: 24px 8px;
}

.results-section h2 {
    background: #2a2a2a;
    margin: 0 0 12px 0;
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 4px solid #ee4c2c;
    font-size: 18px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Empty section styling */
.empty-section {
    text-align: center;
    padding: 40px 20px;
    background: #2a2a2a;
    border-radius: 6px;
    border: 1px solid #333;
    color: #999;
}

.empty-section p {
    margin: 0;
    font-style: italic;
    font-size: 14px;
}

/* Results Grid - Masonry Style */
.results-grid {
    column-count: 8;
    column-gap: 4px;
    column-fill: auto;
    margin-top: 0;
}

/* Near-perfect matches grid styling */
.near-perfect-grid {
    gap: 8px;
    column-gap: 8px;
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 215, 0, 0.08);
}

.near-perfect-grid .result-item {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.near-perfect-grid .result-item:hover {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
}

/* Excellent matches grid styling */
.excellent-grid {
    gap: 6px;
    column-gap: 6px;
    border: 2px solid rgba(238, 76, 44, 0.3);
    border-radius: 8px;
    padding: 8px;
    background: rgba(238, 76, 44, 0.05);
}

.excellent-grid .result-item {
    box-shadow: 0 0 12px rgba(238, 76, 44, 0.3);
}

.excellent-grid .result-item:hover {
    box-shadow: 0 0 20px rgba(238, 76, 44, 0.5);
}

@supports (display: grid) {
    .results-grid {
        display: grid;
        grid-template-columns: repeat(8, 128px);
        gap: 4px;
        column-count: auto;
        justify-content: center;
    }
}

.result-item {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-bottom: 4px;
    break-inside: avoid;
    page-break-inside: avoid;
    background: #000;
    border-radius: 2px;
    overflow: hidden;
    transition: transform 0.15s ease;
}

@supports (display: grid) {
    .result-item {
        display: block;
        margin-bottom: 0;
    }
}

.result-item:hover {
    transform: scale(1.02);
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.result-item.promoted {
    border: 2px solid #ee4c2c;
    box-shadow: 0 0 0 1px #ee4c2c;
}

.promoted-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ee4c2c;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.result-item img {
    width: 100%;
    height: auto;
    display: block;
    border: none;
    border-radius: 2px;
    transition: opacity 0.15s ease;
    object-fit: cover;
    background: #333;
    min-height: 100px;
}

/* Video preview functionality */
.thumb-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
}

.thumb-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 2px;
    z-index: 1;
}

.result-item.video-item:hover .thumb-wrapper img {
    opacity: 0;
}

.result-item.video-item:hover .thumb-wrapper video {
    opacity: 1;
}

/* For non-video items with face URLs - show thumb on hover */
.result-item:not(.video-item) .thumb-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
}

.result-item:not(.video-item) .thumb-wrapper .hover-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 2px;
}

.result-item:not(.video-item) .thumb-wrapper.hover-enabled:hover .hover-img {
    opacity: 1;
}

.result-item img:hover {
    opacity: 1;
}

.result-item img[loading="lazy"] {
    background: linear-gradient(45deg, #333 25%, #444 25%, #444 50%, #333 50%, #333 75%, #444 75%);
    background-size: 20px 20px;
    animation: loading-pattern 1s linear infinite;
}

@keyframes loading-pattern {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 20px;
    }
}

/* Always-visible score bar */
.score-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 2;
}

.score-fill {
    position: relative;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4444 0%, #ffaa00 50%, #44ff44 100%);
    transition: clip-path 0.3s ease;
}

.score-text {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    text-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 3;
}

.overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 8px 6px 4px 6px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 4;
}

.result-item:hover .overlay {
    opacity: 1;
    pointer-events: auto;
}

.rank {
    color: #ee4c2c;
    font-weight: bold;
    font-size: 10px;
    display: inline-block;
    margin-right: 6px;
    opacity: 0.8;
}

.score {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.item-id {
    color: rgba(255, 255, 255, 0.7);
    font-size: 9px;
    margin-top: 2px;
}

.info {
    margin: 0;
}

/* Action Buttons */
.actions {
    margin-top: 4px;
    display: flex;
    gap: 4px;
}

.view-original, .find-similar {
    display: inline-block;
    padding: 2px 6px;
    color: white;
    text-decoration: none;
    border-radius: 2px;
    font-size: 9px;
    transition: background-color 0.15s ease;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.view-original:hover {
    background: #ee4c2c;
    text-decoration: none;
    border-color: #ee4c2c;
}

.find-similar:hover {
    background: #ee4c2c;
    text-decoration: none;
    border-color: #ee4c2c;
}

/* Back Link */
.back-link {
    text-align: center;
    margin-top: 30px;
}

.back-link a {
    color: #007bff;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s ease;
}

.back-link a:hover {
    text-decoration: underline;
    color: #0056b3;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

/* Responsive Design */
@media (max-width: 1080px) {
    .content {
        max-width: 920px;
    }

    .results-grid {
        column-count: 7;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(7, 128px);
            justify-content: center;
        }
    }
}

@media (max-width: 950px) {
    .content {
        max-width: 788px;
    }

    .results-grid {
        column-count: 6;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(6, 128px);
            justify-content: center;
        }
    }
}

@media (max-width: 820px) {
    .content {
        max-width: 656px;
    }

    .results-grid {
        column-count: 5;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(5, 128px);
            justify-content: center;
        }
    }
}

@media (max-width: 688px) {
    body {
        padding: 4px;
    }

    .content {
        max-width: 520px;
    }

    .results-section {
        margin: 16px 4px;
    }

    .results-section h2 {
        padding: 8px 12px;
        font-size: 16px;
    }

    .results-grid {
        column-count: 4;
        column-gap: 2px;
    }

    .excellent-grid {
        gap: 3px;
        column-gap: 3px;
        padding: 4px;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(4, 128px);
            gap: 2px;
            justify-content: center;
        }
    }

    .result-item {
        margin-bottom: 2px;
    }

    .navigation {
        margin-bottom: 15px;
    }

    .nav-link {
        display: block;
        margin: 5px auto;
        max-width: 200px;
    }

    input[type="text"] {
        padding: 12px;
        font-size: 14px;
    }

    h2 {
        margin: 15px 4px 8px 4px;
        font-size: 16px;
    }
}

@media (max-width: 556px) {
    .content {
        max-width: 388px;
    }

    .results-grid {
        column-count: 3;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(3, 128px);
            justify-content: center;
        }
    }
}

@media (max-width: 424px) {
    .content {
        max-width: 260px;
    }

    .results-grid {
        column-count: 2;
    }

    @supports (display: grid) {
        .results-grid {
            grid-template-columns: repeat(2, 128px);
            justify-content: center;
        }
    }

    .query-image {
        max-width: 250px;
        max-height: 250px;
    }
}

/* Face Detection Visualization */
.detected-faces-section {
    margin: 20px 0;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 8px;
    border: 1px solid #333;
}

.detected-faces-section h3 {
    margin: 0 0 15px 0;
    color: #fff;
    font-size: 18px;
    text-align: center;
}

.detected-faces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.detected-face {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s ease;
}

.detected-face.selected {
    border-color: #ee4c2c;
    background: #2a2a2a;
    box-shadow: 0 0 10px rgba(238, 76, 44, 0.3);
}

.face-thumbnail {
    width: 112px;
    height: 112px;
    border-radius: 6px;
    border: 1px solid #444;
    margin-bottom: 8px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    object-fit: cover;
}

.detected-face.selected .face-thumbnail {
    border-color: #ee4c2c;
    box-shadow: 0 0 5px rgba(238, 76, 44, 0.5);
}

.face-label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #ccc;
}

.face-label.selected-label {
    color: #ee4c2c;
}

.face-confidence {
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

.face-selection-note {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 10px 0 0 0;
    font-style: italic;
}

.face-info {
    margin: 15px 0;
    padding: 10px 15px;
    background: #2a2a2a;
    border-radius: 6px;
    border-left: 4px solid #4CAF50;
    color: #fff;
}

.face-info.error {
    border-left-color: #f44336;
    background: #2a1f1f;
}

/* Responsive design for face detection */
@media (max-width: 768px) {
    .detected-faces-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

    .face-thumbnail {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .detected-faces-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .detected-face {
        padding: 8px;
    }

    .face-thumbnail {
        width: 60px;
        height: 60px;
    }
}

/* Recognized Faces Section for face search pages */
.recognized-faces-section {
    margin-top: 20px;
    padding: 15px;
    background: #1f1f1f;
    border-radius: 6px;
    border: 1px solid #333;
}

.recognized-faces-section h3 {
    margin: 0 0 15px 0;
    color: #ee4c2c;
    font-size: 16px;
    font-weight: 500;
    text-align: left;
}

.faces-loading {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

.faces-loading span {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.recognized-faces-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 12px;
    justify-items: center;
}

.recognized-face-item {
    position: relative;
    background: #2a2a2a;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #444;
    transition: all 0.2s ease;
    cursor: pointer;
    max-width: 112px;
}

.recognized-face-item:hover {
    transform: scale(1.05);
    border-color: #ee4c2c;
    box-shadow: 0 4px 12px rgba(238, 76, 44, 0.3);
}

.recognized-face-item img {
    width: 112px;
    height: 112px;
    object-fit: cover;
    display: block;
}

.recognized-face-item .face-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: #fff;
    padding: 4px 6px;
    font-size: 11px;
    text-align: center;
    font-weight: 500;
}

/* Responsive design for recognized faces */
@media (max-width: 768px) {
    .recognized-faces-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .recognized-face-item {
        max-width: 80px;
    }

    .recognized-face-item img {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .recognized-faces-container {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
    }

    .recognized-face-item {
        max-width: 60px;
    }

    .recognized-face-item img {
        width: 60px;
        height: 60px;
    }

    .recognized-face-item .face-label {
        font-size: 9px;
        padding: 2px 4px;
    }
}