/* search.css - Modern, simplified search interface */

/* =========================
   MODERN SEARCH INTERFACE
   ========================= */

.search-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.search-input-container {
    margin-bottom: 1.5rem;
}

.search-input-wrapper {
    position: relative;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    flex: 1;
    min-width: 0;
}

.search-input-wrapper:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.search-input-wrapper:focus-within {
    border-color: var(--clover-purple);
    box-shadow: 0 4px 16px rgba(60, 120, 253, 0.15);
}

.search-textarea {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    padding: 20px 70px 20px 24px;
    font-size: 16px;
    line-height: 1.5;
    color: #1f2937;
    resize: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.search-textarea::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Actions container (mic + submit) positioned inside input wrapper */
.search-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.search-submit-btn {
    background: var(--clover-purple);
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.search-submit-btn:hover:not(:disabled) {
    background: #2b5fd9;
    transform: scale(1.05);
}

.search-submit-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.search-submit-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* =========================
   CHARACTER COUNTER
   ========================= */

.char-counter-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 24px 0;
    font-size: 11px;
}

.char-counter {
    color: #9ca3af;
    font-size: 11px;
    white-space: nowrap;
}

.char-counter.warning {
    color: #d97706;
}

.char-counter.danger {
    color: #dc2626;
    font-weight: 600;
}

.char-limit-upsell {
    color: #9ca3af;
    font-size: 11px;
}

.char-limit-upsell a {
    color: var(--clover-purple);
    text-decoration: none;
    font-weight: 500;
}

.char-limit-upsell a:hover {
    text-decoration: underline;
}

/* =========================
   QUERY TEMPLATES
   ========================= */

.query-templates {
    margin-top: 16px;
}

.template-label {
    margin-bottom: 12px;
}

.template-label-text {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-btn {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.template-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.template-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.template-icon {
    font-size: 16px;
    opacity: 0.8;
}

/* =========================
   SEARCH PROCESSING
   ========================= */

.processing-step {
    transition: all 0.3s ease;
    opacity: 0.5;
    border-radius: 8px;
}

.processing-step.active {
    opacity: 1;
    background-color: #f0f5ff;
    box-shadow: 0 2px 4px rgba(60, 120, 253, 0.1);
}

.processing-step.completed {
    opacity: 1;
    background-color: #f0f9f0;
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.1);
}

.processing-step.error {
    opacity: 1;
    background-color: #ffebee;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.1);
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 14px;
}

.step-icon.pending {
    background-color: #6c757d;
    color: white;
}

.step-icon.active {
    background-color: var(--clover-purple);
    color: white;
    animation: pulse 2s infinite;
}

.step-icon.completed {
    background-color: #198754;
    color: white;
}

.step-icon.error {
    background-color: #dc3545;
    color: white;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(60, 120, 253, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(60, 120, 253, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(60, 120, 253, 0); }
}

.search-insights {
    background: linear-gradient(90deg, var(--gradient-cyan) 0%, var(--gradient-purple) 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(60, 120, 253, 0.3);
}

.insight-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 14px;
}

.insight-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    opacity: 0.9;
    font-size: 16px;
}

/* =========================
   PDF ATTACHMENT INTEGRATION
   ========================= */

/* New flex container for external PDF button */
.search-input-with-attachment {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

/* External PDF attachment button */
.pdf-attachment-button-external {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    font-size: 18px;
    gap: 4px;
    flex-shrink: 0;
    align-self: stretch;
}

.pdf-attachment-button-external:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pdf-attachment-button-external:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pdf-attachment-button-external.has-files {
    color: var(--clover-purple);
    background: #f0f5ff;
    border-color: #93b4fd;
}

.pdf-attachment-button-external.has-files:hover {
    background: #e0ebff;
    border-color: #6b9cfd;
    color: #2b5fd9;
}

/* Legacy styles for old internal button (keep for compatibility) */
.pdf-attachment-button {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 8px 6px;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: auto;
    font-size: 18px;
    z-index: 2;
    gap: 2px;
}

.pdf-attachment-button:hover:not(:disabled) {
    background: #f3f4f6;
    color: #374151;
    transform: translateY(-50%) scale(1.05);
}

.pdf-attachment-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.pdf-attachment-button.has-files {
    color: var(--clover-purple);
    background: #f0f5ff;
}

.pdf-attachment-button.has-files:hover {
    background: #e0ebff;
    color: #2b5fd9;
}

.pdf-button-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-file-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--clover-purple);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pdf-lock-overlay {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    color: #dc2626;
}

.pdf-attachment-text {
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    color: inherit;
    white-space: nowrap;
    user-select: none;
}

/* =========================
   AUDIO INPUT BUTTON (INLINE)
   ========================= */

.audio-input-btn-inline {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-input-btn-inline:hover:not(.listening):not(:disabled) {
    color: #6b7280;
    background: #f3f4f6;
}

.audio-input-btn-inline--unsupported,
.audio-input-btn-inline:disabled {
    color: #d1d5db;
    cursor: not-allowed;
    background: transparent;
}

.audio-input-btn-inline--unsupported:hover,
.audio-input-btn-inline:disabled:hover {
    color: #d1d5db;
    background: transparent;
}

.audio-input-btn-inline.listening {
    color: #dc2626;
    background: #fef2f2;
}

.audio-input-btn-inline.listening:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* Recording ripple animation */
.audio-input-btn-inline.listening::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #fca5a5;
    animation: mic-ripple 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes mic-ripple {
    0% {
        width: 36px;
        height: 36px;
        opacity: 0.8;
    }
    100% {
        width: 56px;
        height: 56px;
        opacity: 0;
    }
}

/* File chips: search-page margin override (base styles in file-chips.css) */
.file-chips-container {
    margin-left: 76px; /* Account for external PDF button + gap */
}

/* Legacy: Adjust textarea padding when PDF button is present (internal button) */
.search-textarea.has-pdf-button {
    padding-left: 52px;
}

/* =========================
   RESPONSIVE DESIGN
   ========================= */

@media (max-width: 768px) {
    .search-textarea {
        padding: 16px 60px 16px 20px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .search-textarea.has-pdf-button {
        padding-left: 52px;
    }

    .search-actions {
        right: 10px;
    }

    .search-submit-btn {
        width: 40px;
        height: 40px;
    }

    .template-buttons {
        flex-direction: column;
    }

    .template-btn {
        justify-content: center;
        text-align: center;
    }

    /* External PDF button mobile styles */
    .search-input-with-attachment {
        gap: 8px;
    }

    .pdf-attachment-button-external {
        min-width: 56px;
        padding: 10px 6px;
        font-size: 16px;
    }

    .pdf-attachment-text {
        font-size: 8px;
    }

    /* Audio input inline button mobile styles */
    .audio-input-btn-inline {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .audio-input-btn-inline.listening::before {
        width: 32px;
        height: 32px;
    }

    /* Legacy internal PDF button mobile styles */
    .pdf-attachment-button {
        min-width: 36px;
        height: auto;
        font-size: 16px;
        padding: 6px 4px;
    }

    .file-chips-container {
        margin-left: 64px; /* Smaller margin for mobile */
    }
}

/* =========================
   UTILITY ANIMATIONS
   ========================= */

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

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

.stage-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(var(--bs-primary-rgb), 0.2);
    border-radius: 50%;
    border-top-color: var(--bs-primary);
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
    margin-right: 0.25rem;
}
