/* Wine Discovery - Clean Modern Design */

:root {
    --wine-red: #722F37;
    --wine-dark: #4A1C23;
    --wine-light: #A94442;
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #E5E5E5;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure hidden attribute works */
[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content > div:first-child {
    text-align: left;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--wine-red);
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.logout-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    color: var(--wine-red);
    border-color: var(--wine-red);
}

/* Login Section */
.login-section {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card h2 {
    color: var(--wine-dark);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.login-card > p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-card .form-group {
    text-align: left;
}

.login-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--wine-red);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.login-btn:hover:not(:disabled) {
    background: var(--wine-dark);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-hint {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.login-hint.success {
    color: #059669;
}

.login-hint.error {
    color: #DC2626;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.tab:hover {
    background: rgba(114, 47, 55, 0.05);
    color: var(--wine-red);
}

.tab.active {
    background: rgba(114, 47, 55, 0.1);
    color: var(--wine-red);
    font-weight: 500;
}

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

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

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--wine-red);
    background: rgba(114, 47, 55, 0.02);
}

.dropzone-content {
    color: var(--text-secondary);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.dropzone p {
    margin-bottom: 0.25rem;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Image Preview */
.image-preview {
    position: relative;
    margin-top: 1rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

.remove-image {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-image:hover {
    background: rgba(0,0,0,0.8);
}

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--wine-red);
    box-shadow: 0 0 0 3px rgba(114, 47, 55, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Discover Button */
.discover-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--wine-red);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 1.5rem;
    transition: background 0.2s, transform 0.1s;
}

.discover-btn:hover:not(:disabled) {
    background: var(--wine-dark);
}

.discover-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.discover-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Section */
.status-section {
    margin-top: 2rem;
}

.status-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.status-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.status-icon .spinner {
    width: 24px;
    height: 24px;
    border-color: var(--wine-light);
    border-top-color: var(--wine-red);
}

.status-text {
    font-weight: 500;
    color: var(--text-primary);
}

.status-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding-left: 2.25rem;
}

/* Result Section */
.result-section {
    margin-top: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.result-header h2 {
    font-size: 1.5rem;
    color: var(--wine-red);
}

.result-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.result-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

/* Markdown Styling */
.result-content h1,
.result-content h2,
.result-content h3 {
    color: var(--wine-dark);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.result-content h1:first-child,
.result-content h2:first-child {
    margin-top: 0;
}

.result-content p {
    margin-bottom: 1rem;
}

.result-content ul,
.result-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.result-content li {
    margin-bottom: 0.5rem;
}

.result-content blockquote {
    border-left: 3px solid var(--wine-red);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.result-content strong {
    color: var(--wine-dark);
}

.result-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Sources */
.result-sources {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.result-sources h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.result-sources ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-sources li {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
}

.result-sources a {
    color: var(--wine-light);
    text-decoration: none;
}

.result-sources a:hover {
    text-decoration: underline;
}

/* Error Section */
.error-section {
    margin-top: 2rem;
}

.error-card {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
}

.error-card h3 {
    color: #DC2626;
    margin-bottom: 0.5rem;
}

.error-card p {
    color: #7F1D1D;
    margin-bottom: 1rem;
}

.retry-btn {
    padding: 0.75rem 1.5rem;
    background: #DC2626;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #B91C1C;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        min-width: 100px;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-content {
        padding: 1rem;
    }
}
