/* style.css - Clean, Premium Glassmorphism Theme */

:root {
    --bg-primary: #f0f4f8;          /* Light slate blue-grey background */
    --bg-card: rgba(255, 255, 255, 0.85); /* Bright white glass */
    --border-color: rgba(15, 23, 42, 0.08); /* Dark subtle border */
    --text-primary: #0f172a;        /* Deep slate for high contrast visibility */
    --text-secondary: #475569;      /* Slate-600 */
    
    --color-primary: #4f46e5;      /* Indigo */
    --color-primary-hover: #4338ca;
    --color-accent: #0284c7;       /* Sky blue for higher contrast */
    
    /* pH standard theme colors for UI highlights (darker for readability) */
    --color-acid: #dc2626;         
    --color-neutral: #15803d;      
    --color-alkali: #6d28d9;       
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 16px;
    --transition-speed: 0.25s;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding: 2rem 1.5rem;
}

/* Background Glowing Orbs */
.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25; /* Higher opacity to show up well on screen projection */
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--color-primary);
    top: -100px;
    right: 5%;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--color-accent);
    bottom: -150px;
    left: -50px;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

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

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 15px rgba(6, 182, 212, 0.4));
}

.logo h1 {
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
    margin-bottom: 0.75rem;
}

/* API Settings bar in header */
.api-settings {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.35rem 1rem;
    margin-top: 0.5rem;
    transition: border-color var(--transition-speed);
}

.api-settings:focus-within {
    border-color: rgba(6, 182, 212, 0.4);
}

.key-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

#api-key-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.8rem;
    width: 250px;
    outline: none;
}

#api-key-input::placeholder {
    color: rgba(15, 23, 42, 0.3); /* dark placeholder */
    font-family: var(--font-sans);
}

.btn-small {
    background-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    border: none;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: opacity var(--transition-speed), transform 0.1s;
}

.btn-small:hover {
    opacity: 0.9;
}

.btn-small:active {
    transform: scale(0.96);
}

/* Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

/* Base Card Style */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.75rem;
    box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08); /* softer dark shadow for light mode */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Drop Zone Styles */
.drop-zone {
    border: 2px dashed rgba(15, 23, 42, 0.15);
    border-radius: 12px;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-speed), background-color var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--color-accent);
    background-color: rgba(6, 182, 212, 0.04);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    transition: transform var(--transition-speed);
}

.drop-zone:hover .upload-icon {
    transform: scale(1.1) translateY(-5px);
}

.drop-zone h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.drop-zone p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.formats-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: rgba(15, 23, 42, 0.05);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    margin-top: 0.5rem;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Editor Container */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    background-color: rgba(15, 23, 42, 0.05); /* light neutral grey */
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-canvas {
    max-width: 100%;
    display: block;
    cursor: crosshair;
}

.instruction-bar {
    display: flex;
    gap: 0.5rem;
    background-color: rgba(2, 132, 199, 0.08); /* light sky blue */
    border: 1px solid rgba(2, 132, 199, 0.15);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.9rem;
    color: #0369a1; /* dark blue text for contrast */
}

.instruction-bar p {
    margin: 0;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Buttons */
.btn {
    font-family: var(--font-sans);
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color var(--transition-speed), transform 0.1s, box-shadow var(--transition-speed);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.btn-secondary {
    background-color: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(15, 23, 42, 0.08);
}

.hidden {
    display: none !important;
}

/* Results Column & Placeholder */
.results-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.placeholder-card {
    text-align: center;
    padding: 5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3.5rem;
    opacity: 0.6;
}

.placeholder-card h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.placeholder-card p {
    font-size: 0.95rem;
    max-width: 320px;
}

/* Results Panel Details */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.metric-box {
    background-color: rgba(15, 23, 42, 0.03); /* soft grey box */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.metric-val {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric-tag {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.35rem;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    background-color: var(--color-neutral);
    color: white;
}

/* Confidence Bar */
.conf-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(15, 23, 42, 0.08);
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.conf-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transition: width 0.8s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Color Match swatches */
.color-match-viewer {
    background-color: rgba(15, 23, 42, 0.02);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.color-match-viewer h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.swatches-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.swatch-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.color-swatch {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    border: 2px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
    background-color: #334155;
    transition: background-color 0.4s ease;
}

.swatch-divider {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

/* AI Cards styling */
.ai-card {
    border-left: 4px solid var(--color-accent);
}

.quality-card {
    border-left-color: #eab308; /* yellow warning indicator */
}

.science-card {
    border-left-color: var(--color-primary);
}

.card-title-ai {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-title-ai h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.ai-icon {
    font-size: 1.25rem;
}

.ai-content-box {
    background-color: rgba(15, 23, 42, 0.03);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.ai-text {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Chat box */
.chat-card {
    padding: 1.25rem;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.chat-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chat-icon {
    font-size: 1.15rem;
}

.chat-messages {
    height: 180px;
    overflow-y: auto;
    background-color: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.message {
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.88rem;
    word-break: break-word;
    animation: fadeIn 0.25s ease-out;
}

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

.system-message {
    background-color: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.02);
    color: var(--text-secondary);
    align-self: center;
    text-align: center;
    max-width: 95%;
    font-size: 0.8rem;
}

.user-message {
    background-color: var(--color-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.bot-message {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-form {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: border-color var(--transition-speed);
}

#chat-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.btn-send {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color var(--transition-speed);
}

.btn-send:hover {
    background-color: var(--color-accent);
}

/* Global Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(240, 244, 248, 0.85); /* light blurred overlay */
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loader-message {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

/* Warning Banner Styles */
.warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.25rem;
    animation: slideDown 0.3s ease-out;
}

.warning-icon {
    font-size: 1.25rem;
    line-height: 1;
}

#warning-text {
    font-size: 0.88rem;
    color: #fca5a5; /* light red text */
    line-height: 1.4;
    margin: 0;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* App Footer Credits */
.app-footer {
    max-width: 1200px;
    margin: 3.5rem auto 1.5rem auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.footer-credits {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.6;
    background: linear-gradient(135deg, #1e40af, #2563eb); /* Royal Blue to Bright Blue */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 2px solid rgba(37, 99, 235, 0.15);
    padding-bottom: 0.5rem;
    display: inline-block;
    letter-spacing: 0.01em;
}

/* Upload Buttons in Drop Zone */
.upload-buttons {
    display: flex;
    gap: 1rem;
    margin: 1.25rem 0;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

.upload-buttons .btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

/* Crop Slider Styles */
.slider-wrapper {
    margin: 1.25rem 0;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.slider-val {
    color: #06b6d4; /* Cyan accent color */
    background: rgba(6, 182, 212, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.crop-slider {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.crop-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #06b6d4;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(6, 182, 212, 0.3);
    transition: transform 0.1s;
}

.crop-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Footer Documentation Links */
.footer-links {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.footer-link:hover {
    color: #2563eb; /* Bright blue hover */
    text-decoration: underline;
}

.link-divider {
    color: var(--border-color);
}

/* Responsive mobile-first screen optimizations */
@media (max-width: 600px) {
    body {
        padding: 1rem 0.5rem;
    }
    
    .app-header {
        margin-bottom: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.7rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .card {
        padding: 1.15rem;
        border-radius: 12px;
    }
    
    .drop-zone {
        padding: 2.25rem 1rem;
    }
    
    .canvas-wrapper {
        max-height: 55vh;
        border-radius: 12px;
    }
    
    #image-canvas {
        max-height: 100%;
        object-fit: contain;
    }
    
    .upload-buttons {
        gap: 0.75rem;
        margin: 1rem 0;
    }
    
    .upload-buttons .btn {
        width: 100%; /* stack buttons vertically on very small phones */
        padding: 0.75rem 1rem;
        font-size: 0.88rem;
    }
    
    .editor-actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .editor-actions .btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }
    
    .footer-credits {
        font-size: 0.92rem;
        padding-bottom: 0.35rem;
    }
    
    .app-footer {
        margin: 2rem auto 1rem auto;
    }
}
