/* Jerusalem Municipality Chatbot - Styles
   ========================================= */

/* CSS Variables */
:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #bbdefb;
    --secondary-color: #424242;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;

    --bg-color: #f5f5f5;
    --surface-color: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;

    --bot-message-bg: #ffffff;
    --user-message-bg: #e3f2fd;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 3px 6px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.12);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.15), 0 3px 6px rgba(0,0,0,0.10);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --transition: all 0.2s ease;

    --header-height: 70px;
    --input-height: 70px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: url('/static/bg-jlm.png') repeat;
    background-size: 600px 600px;
    background-color: #f5f5f5;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-lg);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.75rem 1rem;
    height: auto;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo-emoji {
    font-size: 26px;
    line-height: 1;
}

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.header-text h1 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.header-text p {
    font-size: 0.75rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.25);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-color);
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

/* Message Styles */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
}

.bot-avatar {
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
}

.avatar-emoji {
    font-size: 22px;
    line-height: 1;
}

.user-message .message-avatar {
    background-color: var(--secondary-color);
}

.message-content {
    background-color: var(--bot-message-bg);
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.user-message .message-content {
    background-color: var(--user-message-bg);
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Sources Section */
.sources-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.sources-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.sources-list {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sources-list a {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}

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

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.quick-action-btn .icon {
    font-size: 1rem;
}

/* Message with Report Summary */
.report-card {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 0.75rem;
}

.report-card h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.report-card .report-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    font-size: 0.9rem;
}

.report-card .report-item:last-child {
    margin-bottom: 0;
}

.submit-106-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.submit-106-btn:hover {
    background-color: #43a047;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.submit-106-btn svg {
    width: 18px;
    height: 18px;
}

/* Photo Preview */
.photo-preview {
    position: relative;
    padding: 0.5rem 1rem;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

.photo-preview img {
    max-height: 150px;
    max-width: 100%;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.remove-photo-btn {
    position: absolute;
    top: 0.75rem;
    right: 1.25rem;
    width: 28px;
    height: 28px;
    background-color: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-photo-btn:hover {
    background-color: var(--error-color);
}

.remove-photo-btn svg {
    width: 16px;
    height: 16px;
}

/* Input Area */
.input-area {
    background-color: var(--surface-color);
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background-color: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
}

.btn-attach,
.btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-attach {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-attach:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

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

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

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

.btn-attach svg,
.btn-send svg {
    width: 20px;
    height: 20px;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.5;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: var(--radius-full);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-close svg {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: 1.25rem;
}

.report-summary {
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.report-summary .summary-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.report-summary .summary-item:last-child {
    margin-bottom: 0;
}

.report-summary .summary-icon {
    font-size: 1.125rem;
}

.report-summary .summary-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

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

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-primary svg,
.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.modal-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-note svg {
    flex-shrink: 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.typing-indicator .message-content {
    padding: 1rem;
}

/* Photo in Message */
.message-photo {
    max-width: 200px;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

/* Scrollbar */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: var(--radius-full);
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .header-text p {
        display: none;
    }

    .message {
        max-width: 90%;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-action-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-actions {
        flex-direction: column;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--secondary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    z-index: 200;
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.success {
    background-color: var(--success-color);
}

.toast.error {
    background-color: var(--error-color);
}

/* Initialization Loader */
.init-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.init-loader-content {
    text-align: center;
    color: white;
}

.init-loader-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.init-loader-content p {
    font-size: 1rem;
    opacity: 0.9;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

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

.loader-error {
    text-align: center;
    color: white;
    padding: 2rem;
    max-width: 400px;
}

.loader-error h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.loader-error p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.retry-btn {
    background-color: white;
    color: var(--primary-color);
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.retry-btn:hover {
    background-color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
