:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --success: #10b981;
    --error: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow-x: hidden;
}

/* Background Animations */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--primary);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--accent);
    animation-delay: -5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

.container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="password"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
}

.upload-section {
    text-align: center;
    position: relative;
    border: 2px dashed var(--border-color);
}

.upload-section h2 {
    font-size: 1.2rem;
    color: var(--accent);
    margin-top: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.upload-section.drag-active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
}

.upload-content h3 {
    font-weight: 500;
}

.upload-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-extract {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-extract::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-extract:hover::after {
    left: 100%;
}

.btn-extract:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border-color);
}

#preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.file-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* PDF document preview card (used in the Template section) */
.pdf-doc-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    margin: 1rem 0 0.5rem;
    text-align: left;
    transition: border-color 0.2s;
}

.pdf-doc-preview svg {
    color: var(--primary);
    flex-shrink: 0;
    opacity: 0.9;
}

.pdf-doc-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.pdf-doc-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-doc-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.spinner {
    animation: rotate 2s linear infinite;
    width: 24px;
    height: 24px;
}

.spinner .path {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

.result-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.result-section h3 {
    font-size: 1.2rem;
    margin: 1.5rem 0 0.5rem 0;
    color: var(--text-muted);
}

.validation-status {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.validation-status.success {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.validation-status.error {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
}

.validation-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.validation-category {
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.validation-category h4 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-category.missing h4 { color: #f59e0b; }
.validation-category.unnecessary h4 { color: #ef4444; }
.validation-category.misordered h4 { color: #3b82f6; }

.validation-category ul {
    list-style-type: none;
    margin-left: 1rem;
}

.validation-category li {
    position: relative;
    padding-left: 1rem;
    margin-bottom: 0.25rem;
}

.validation-category li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.result-content {
    background: transparent;
    padding: 0;
    min-height: 100px;
    border: none;
}

.comparison-wrapper {
    position: relative;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 1rem;
    overflow: hidden;
}

.comparison-container {
    display: flex;
    justify-content: space-between;
    position: relative;
    min-height: 200px;
}

.comparison-column {
    width: 45%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2;
}

.comparison-column h4 {
    text-align: center;
    color: var(--accent);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.ing-item {
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    word-break: break-word;
}

.ing-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.ing-item.missing {
    border-left: 4px solid #f59e0b;
}

.ing-item.unnecessary {
    border-left: 4px solid #ef4444;
}

.ing-item.misordered {
    border-left: 4px solid #3b82f6;
}

.ing-item.matched {
    border-left: 4px solid #10b981;
}

.comparison-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.template-item-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.percentage-badge {
    width: 50px;
    text-align: right;
    margin-right: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.template-item-wrapper .ing-item {
    flex-grow: 1;
    width: 100%;
}

.less-than-one-separator {
    display: flex;
    align-items: center;
    margin: -0.375rem 0; /* Cancel out the parent's flex gap to not affect item separation */
    height: 0;
    line-height: 0;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    z-index: 0;
}

.less-than-one-separator::after {
    content: "";
    flex-shrink: 0;
    width: 200vw;
    height: 1px;
    background-color: var(--text-main);
    margin-left: 0.75rem;
}

#loading-container {
    margin-top: 1rem;
    text-align: center;
}

.loading-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 500;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% 100%;
    animation: loadingBar 2s infinite linear;
    border-radius: 4px;
}

@keyframes loadingBar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

#image-preview, #label-image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#label-image-preview:hover {
    cursor: crosshair;
}

/* Lens Effect */
.lens {
    position: absolute;
    border: 3px solid var(--primary);
    border-radius: 50%;
    width: 500px;
    height: 500px;
    pointer-events: none;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.5);
    background-color: #fff;
    overflow: hidden;
}

.lens-img {
    position: absolute;
    pointer-events: none;
    max-width: none !important;
}

.textarea-wrapper {
    position: relative;
    width: 100%;
}

#label-ingredients-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    color: transparent;
    pointer-events: none;
    border: 1px solid transparent;
    border-radius: 8px;
    z-index: 1;
}

#label-ingredients-edit {
    position: relative;
    width: 100%;
    display: block;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    background: transparent;
    color: inherit;
    z-index: 2;
    margin: 0;
}
