/* ===========================
   imageSearch.css
   Matches styling & theme of chatBot.css
   =========================== */

/* Theme variables (same system as chatBot.css) */
:root{
    --bg-body: #f9fafb;
    --bg-panel: rgba(255,255,255,0.96);
    --text-color: #111827;
    --muted: #6b7280;
    --header-bg: #4f46e5;
    --btn-primary-bg: #667eea;
    --btn-primary-text: #ffffff;
    --border: #e5e7eb;
    --input-border: #d1d5db;
    --preview-bg: #f3f4f6;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 10px 25px rgba(0,0,0,0.12);
}

body[data-theme="dark"], body.dark {
    --bg-body: #0f1724;
    --bg-panel: #111827;
    --text-color: #f8fafc;
    --muted: #9ca3af;
    --header-bg: #4f46e5;
    --btn-primary-bg: #4f46e5;
    --btn-primary-text: #ffffff;
    --border: #374151;
    --input-border: #4b5563;
    --preview-bg: #141922;
    --danger: #ef4444;
    --shadow: 0 8px 20px rgba(0,0,0,0.6);
}

/* Global body */
body{
    margin: 0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 20px;
}

/* Top header (matches chat-header style) */
.header {
    background: var(--header-bg);
    color: #fff;
    border-radius: 14px;
    padding: 12px 18px;
    max-width: 1400px;
    margin: 0 auto 18px;
    box-shadow: var(--shadow);
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
}

/* Header left and right */
.header-left h2{
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}
.header-right {
    display:flex;
    align-items:center;
    gap: 10px;
}

/* small icon style buttons used in header */
.icon-btn{
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.18);
    color: white;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    transition: transform .12s ease, background .12s ease;
}
.icon-btn:hover{ transform: translateY(-2px); }

/* portfolio button in header */
.portfolio-btn{
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 8px 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* Container with two columns */
.container{
    max-width: 1400px;
    margin: 18px auto 40px;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 22px;
    align-items: start;
}

/* Card base styling to mirror chat container look */
.card {
    background: var(--bg-panel);
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Image panel (left) */
.image-panel{
    display:flex;
    flex-direction:column;
    gap: 14px;
}
.image-panel h3{
    margin:0;
    padding: 14px 18px;
    font-size:16px;
    font-weight:700;
    color:var(--text-color);
    background:transparent;
}
.image-preview-list{
    min-height: 220px;
    max-height: 520px;
    overflow-y: auto;
    padding: 12px;
    display:flex;
    flex-direction:column;
    gap:10px;
    background: transparent;
}

/* grid in preview region (if there are images, make grid) */
.image-preview-list .preview-grid {
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(120px,1fr));
    gap: 12px;
}

/* default no-images text */
.no-images{
    margin: 0;
    color: var(--muted);
    padding: 28px;
    text-align: center;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
}

/* individual image box */
.image-box{
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: var(--preview-bg);
    border: 1px solid var(--input-border);
    display:flex;
    align-items:center;
    justify-content:center;
    min-height: 100px;
}

/* thumbnail */
.image-box img, .preview-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display:block;
}

/* remove button on top-right of each preview */
.image-box .remove-btn{
    position:absolute;
    top:8px;
    right:8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition: background .12s ease;
}
.image-box .remove-btn:hover{ background: rgba(0,0,0,0.8); }

/* Upload area */
.upload-section{
    display:flex;
    gap:12px;
    align-items:center;
    flex-wrap: wrap; /* ALLOW WRAPPING */ 
}
.upload-section .paste-hint {
    flex: 1 1 100%; /* TAKE FULL WIDTH ON MOBILE */ 
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    white-space: normal;
    text-align: left;
}
.file-upload-label{
    display:inline-flex;
    align-items:center;
    gap:8px;
    cursor:pointer;
    border:2px dashed var(--input-border);
    padding:10px 14px;
    border-radius:10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.4));
    color: var(--text-color);
    font-weight:700;
}
.file-upload-label input[type="file"]{ display:none; }

.paste-hint{
    font-size:13px;
    color: var(--muted);
    margin: 0 6px;
}

/* Chat panel (right) */
.chat-panel{
    display:flex;
    flex-direction:column;
    gap:12px;
    min-height: 520px;
}

/* response area: chat-like bubbles area */
.response-box{
    max-height: 320px;
    padding: 16px;
    border-radius: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    overflow-y: auto !important;
    min-height: 280px;
}

.response-box p{
    margin: 0;
    color: var(--text-color);
    line-height:1.6;
}

/* placeholder / loading / error states */
.response-box .placeholder-text {
    color: var(--muted);
    padding: 20px;
}
.response-box .loading { color: var(--muted); }

/* Input section area */
.input-section{
    display:flex;
    gap:12px;
    align-items:stretch;
}
#queryInput{
    flex:1;
    resize:none;
    height: 184px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--bg-panel);
    color: var(--text-color);
    font-size: 15px;
}

/* Search button similar to footer-btn.primary in chatBot.css */
.search-btn{
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    min-width: 140px;
    align-self:flex-end;
    transition: background .14s ease, transform .12s ease;
}
.search-btn:hover{ transform: translateY(-2px); }
.search-btn:disabled{ opacity: 0.6; cursor: not-allowed; transform:none; }

/* Back button container */
.back-container{
    max-width: 1400px;
    margin: 18px auto 40px;
    text-align:center;
}
.back-btn{
    background: var(--bg-panel);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight:700;
    cursor:pointer;
    transition: box-shadow .12s ease, transform .12s ease;
}
.back-btn:hover{ transform: translateY(-3px); box-shadow: var(--shadow); }

/* Small utilities */
.text-muted { color: var(--muted); font-size: 13px; }

/* tiny responsive tweaks */
@media (max-width: 1100px){
    .container{
        grid-template-columns: 360px 1fr;
        gap: 14px;
    }
}

@media (max-width: 820px) {
    .container{
        grid-template-columns: 1fr;  /* stack panels vertically */
        gap: 14px;
    }
    .image-panel { order: 2; }
    .chat-panel  { order: 1; }

    /* Ensure panels take full width */
    .image-panel,
    .chat-panel {
        width: 100%;
    }
    
    /* Make panels scrollable if content is long */
    .image-panel, .chat-panel {
        overflow: hidden; /* prevent accidental horizontal scroll */
    }
    
    /* Response and image preview scroll properly */
    .image-preview-list, .response-box {
        max-height: 300px; /* adjustable for mobile */
        overflow-y: auto;
    }
    
    /* Stack textarea and buttons vertically on mobile */
    .input-section {
        display: flex;
        flex-direction: column;  /* stack vertically */
        gap: 8px;
        width: 100%;
    }

    #queryInput {
        width: 100% !important;   /* full width */
        box-sizing: border-box;
        height: 120px;            /* mobile height */
    }

    .search-btn {
        width: 100%;              /* full width below textarea */
        flex: none;
    }

    .mic-btn {
        width: 45px;              /* keep original size */
        align-self: flex-start;   /* keep it on left side */
    }
}

/* Select2 theme compatibility (if used) */
.select2-container--default .select2-selection--single {
  height: 46px !important;
  line-height: 46px !important;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--bg-panel);
  color: var(--text-color) !important;
}

/* small accessible focus styles */
.file-upload-label:focus, .icon-btn:focus, .search-btn:focus, .back-btn:focus, .portfolio-btn:focus {
    outline: 3px solid rgba(99,102,241,0.18);
    outline-offset: 2px;
}

/* chat-bubble compatibility (in case you reuse chat CSS styles) */
.chat-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 15px;
}
.chat-bubble.bot {
    background: var(--preview-bg);
    color: var(--text-color);
    border-top-left-radius: 0;
}
.chat-bubble.user{
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    align-self:flex-end;
    border-top-right-radius: 0;
}

/* Accessibility: reduce-motion */
@media (prefers-reduced-motion: reduce){
    * { transition: none !important; animation: none !important; }
}
	
.mic-btn {
    background: var(--btn-primary-bg);
    color: white;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    border:none;
    transition:0.15s ease;
}

.mic-btn.listening {
    background: #ef4444 !important;
    transform: scale(1.08);
}

.chat-footer-bottom {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: nowrap; /* desktop default */
}
	
.page-wrapper {
    width: 90%;
    max-width: 1400px;
    margin: 30px auto;
    padding: 25px;
    border: 2px solid #d3d3d3;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0px 4px 16px rgba(0,0,0,0.10);
}

body.dark .page-wrapper {
    background: #1e1e1e;
    border-color: #555;
    box-shadow: 0px 4px 20px rgba(255,255,255,0.05);
}
 
/* Wrapper for placing Copy button above boxes */
.copy-btn-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
    margin-top: 6px;
}

/* Blue Copy Button */
.copy-btn {
    background: #667eea;
    color: white;
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}
.copy-btn:hover {
    background: #005dc1;
}

/* Scroll behavior for both fields */
.query-scroll {
    flex: 1;
    resize: none;
    height: 184px !important;
    overflow-y: auto !important;
}

.scroll-y {
    overflow-y: auto !important;
}
	
.ai-reply {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    color: var(--text-color);
}

/* ------------------------------------
   MOBILE RESPONSIVE FIXES
   Applies to screens ≤ 480px
-------------------------------------- */
@media (max-width: 480px) {

    /* Main container auto adjust */
    .chat-container,
    .image-search-box,
    .chatbot-box,
    .search-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 12px !important;
        box-sizing: border-box;
        border-radius: 0 !important;
    }

    /* Headers */
    .header,
    .image-search-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
        text-align: left;
    }

    /* Buttons auto wrap */
    .header button,
    .image-search-header button,
    .action-buttons button {
        width: 100% !important;
        margin: 5px 0 !important;
    }

    /* Textareas */
    textarea,
    #queryInput,
    #imageQueryInput {
        width: 100% !important;
        min-height: 140px !important;
        font-size: 15px !important;
    }

    /* Response box */
    .response-box,
    #responseContainer {
        width: 100% !important;
        max-height: 260px !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }

    /* Upload section */
    .upload-box {
        width: 100% !important;
        flex-direction: column !important;
        text-align: center;
    }

    /* Image thumbnails wrap neatly */
    .thumb-preview {
        width: 90px !important;
        height: 90px !important;
    }

    /* Input + Mic icon row */
    .input-row {
        flex-direction: row !important;
        gap: 8px !important;
    }

    .mic-btn {
        min-width: 44px !important;
        height: 44px !important;
    }

    /* Search buttons */
    .action-buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Portfolio, Theme buttons */
    .footer-buttons {
        flex-direction: column !important;
        gap: 12px !important;
        width: 100%;
    }

    .footer-buttons button {
        width: 100% !important;
    }
}

/* Loader inside Search button */
.search-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.search-btn .spinner {
    border: 3px solid rgba(255,255,255,0.6);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* NEW: Camera Modal */
.camera-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.camera-content {
    background: #000;
    padding: 15px;
    border-radius: 10px;
}

.camera-content video {
    width: 100%;
    max-width: 420px;
    border-radius: 8px;
}

.camera-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    justify-content: center;
}
	