/* ============================================
   COLOR SYSTEM - Google Material Design 3
   ============================================ */
:root {
    /* Primary Colors - Main Actions */
    --color-primary: #1a73e8;
    --color-primary-hover: #1557b0;
    --color-primary-light: #e8f0fe;

    /* Secondary Colors - Brand & Accents */
    --color-secondary: #50bcff;
    --color-secondary-hover: #3da9e6;
    --color-secondary-light: #e3f5ff;

    /* Neutral Colors */
    --color-surface: #ffffff;
    --color-background: #f8f9fa;
    --color-border: #dadce0;
    --color-border-light: #e8eaed;
    --color-text-primary: #202124;
    --color-text-secondary: #5f6368;
    --color-text-disabled: #9aa0a6;

    /* Semantic Colors */
    --color-success: #34a853;
    --color-warning: #fbbc04;
    --color-error: #ea4335;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
    padding: 24px 20px;
    text-align: center;
}

.header-container {
    max-width: 1120px;
    margin: 0 auto;
}

.header-title {
    color: var(--color-secondary);
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.header-subtitle {
    color: #9aa0a6;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* Main Container */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 24px;
    flex: 1;
}

/* Upload Section */
.upload-section {
    margin-bottom: 32px;
}

.upload-area {
    border: none;
    border-radius: 16px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f0f4f8;
    position: relative;
}

.upload-area:hover {
    background-color: #e6eef6;
}

.upload-area.dragover {
    background-color: #dce8f5;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    color: #9ab0c8;
    margin-bottom: 4px;
}

.upload-placeholder h3 {
    font-size: 15px;
    font-weight: 500;
    color: #5f6368;
    margin-bottom: 2px;
}

.upload-placeholder p {
    font-size: 13px;
    color: #9aa0a6;
    margin: 0;
}

.upload-hint {
    font-size: 11px !important;
    color: #bdc3c7 !important;
}

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.change-image-btn {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    color: #5f6368;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.change-image-btn:hover {
    background: #e8eaed;
    color: #3c4043;
}

/* Category Section */
.category-section {
    margin-bottom: 32px;
}

.category-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-label {
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
}

.category-select {
    padding: 12px 16px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: #3c4043;
    cursor: pointer;
    transition: border-color 0.2s;
}

.category-select:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(80, 188, 255, 0.15);
}

/* Search Section */
.search-section {
    text-align: center;
    margin-bottom: 40px;
}

.search-button {
    background: #80bbf9;
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: none;
    min-width: 200px;
}

.search-button:hover:not(:disabled) {
    background: #5a9be6;
    transform: translateY(-1px);
}

.search-button:active {
    transform: translateY(0);
}

.search-button:disabled {
    background: #c0d8f9;
    color: #fff;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 48px 20px;
    background: white;
    border-radius: 16px;
    margin-bottom: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
    border: 4px solid #f1f3f4;
    border-top: 4px solid #50bcff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text h3 {
    font-size: 16px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 8px;
}

.loading-text p {
    font-size: 14px;
    color: #5f6368;
}

/* Section Headers */
.section-header {
    margin-bottom: 24px;
    text-align: center;
}

.section-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: #5f6368;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.results-count {
    font-size: 12px;
    color: #9aa0a6;
}

/* Results Section */
.results-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-top: 24px;
}

/* Result Card */
.result-card {
    background: var(--color-surface);
    border: none;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.25s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card-image-container {
    position: relative;
    width: 100%;
    height: 320px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

.similarity-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    box-shadow: none;
    letter-spacing: 0.2px;
}

.card-caption-name {
    padding: 12px 16px 4px;
    font-size: 13px;
    font-weight: 600;
    color: #202124;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #ffffff;
    letter-spacing: -0.1px;
}

.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.card-explanation {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.7;
    background: #f7f8fa;
    padding: 14px 16px;
    border-radius: 10px;
    border: none;
    position: relative;
}

.explanation-text {
    margin: 0;
}

.read-more-btn {
    background: none;
    border: none;
    color: #80bbf9;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 6px;
    text-decoration: none;
    transition: color 0.2s;
}

.read-more-btn:hover {
    color: #5a9be6;
    text-decoration: underline;
}

/* No Results Section */
.no-results-section {
    text-align: center;
    padding: 64px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.no-results-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-results-icon {
    color: #9aa0a6;
    margin-bottom: 24px;
}

.no-results-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #202124;
    margin-bottom: 12px;
}

.no-results-content p {
    font-size: 14px;
    color: #5f6368;
    line-height: 1.6;
}

/* Error Section */
.error-section {
    text-align: center;
    padding: 48px 20px;
    background: white;
    border-radius: 16px;
    border-left: 4px solid #ea4335;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.error-content {
    max-width: 400px;
    margin: 0 auto;
}

.error-icon {
    color: #ea4335;
    margin-bottom: 20px;
}

.error-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #202124;
    margin-bottom: 8px;
}

.error-content p {
    font-size: 14px;
    color: #5f6368;
    margin-bottom: 20px;
}

.retry-button {
    background: #80bbf9;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.retry-button:hover {
    background: #5a9be6;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }

    .header {
        padding: 20px 16px;
    }

    .header-title {
        font-size: 22px;
    }

    .upload-area {
        padding: 32px 20px;
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .caption-section,
    .results-section {
        padding: 0;
    }

    .search-button {
        padding: 14px 28px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 20px;
    }

    .header-subtitle {
        font-size: 11px;
    }

    .upload-area {
        padding: 24px 16px;
    }

    .upload-placeholder h3 {
        font-size: 14px;
    }

    .search-button {
        width: 100%;
        max-width: 280px;
    }
}

/* Accessibility */
.search-button:focus,
.category-select:focus,
.change-image-btn:focus,
.retry-button:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(80, 188, 255, 0.15);
}

.setting-slider:focus {
    outline: 2px solid var(--color-secondary);
}

/* Animations */
.caption-section,
.results-section,
.no-results-section,
.error-section {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeInUp 0.4s ease-out;
    animation-fill-mode: both;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f3f4;
}

::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9aa0a6;
}

/* Search Settings */
.search-settings {
    background: white;
    border-radius: 12px;
    border: 1px solid #e8eaed;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.08);
}

.search-settings .section-header {
    margin-bottom: 20px;
}

.search-settings .section-header h3 {
    color: #5f6368;
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.3px;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    color: #5f6368;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-label span {
    color: var(--color-secondary);
    font-weight: 600;
}

.setting-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e8eaed;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
    cursor: pointer;
}

.setting-slider:hover {
    opacity: 1;
}

.setting-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-secondary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.05);
}

.setting-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-secondary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Mobile Responsiveness for Settings */
@media (max-width: 768px) {
    .search-settings {
        padding: 20px;
    }
    
    .settings-content {
        gap: 16px;
    }
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #80bbf9;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(128, 187, 249, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
    z-index: 1000;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: #5a9be6;
    box-shadow: 0 4px 16px rgba(128, 187, 249, 0.5);
}
