/* Custom CSS for Dealboards */

/* Global Font Settings */
* {
    font-family: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    font-family: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* Smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Table hover effects */
tbody tr {
    transition: background-color 0.2s ease;
}

/* Status badge animations */
.status-badge {
    transition: transform 0.2s ease;
}

.status-badge:hover {
    transform: scale(1.05);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Highlight animations for incremental updates */
@keyframes highlight-new {
    0% { background-color: #86efac; }
    100% { background-color: transparent; }
}

@keyframes highlight-update {
    0% { background-color: #fde047; }
    100% { background-color: transparent; }
}

.highlight-new {
    animation: highlight-new 3s ease;
}

.highlight-update {
    animation: highlight-update 3s ease;
}

/* Status select dropdown */
.status-select {
    appearance: none;
    transition: all 0.2s ease;
}

.status-select:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.status-select option {
    background-color: white;
    color: black;
    padding: 0.5rem;
}

/* Bulk edit mode styles */
.bulk-edit-mode .editable-cell {
    cursor: text;
    transition: background-color 0.2s ease;
}

.bulk-edit-mode .editable-cell:hover {
    background-color: #fef3c7;
}

.bulk-edit-mode .editable-cell.editing {
    background-color: #fef3c7;
    padding: 0;
}

.bulk-edit-mode .editable-value {
    display: inline-block;
    padding: 0.5rem 1rem;
    min-height: 2rem;
    border: 1px dashed #d1d5db;
    border-radius: 0.25rem;
    width: 100%;
}

.bulk-edit-mode .editable-cell input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 2px solid #3b82f6;
    border-radius: 0.25rem;
    outline: none;
    font-size: 0.875rem;
}

.bulk-edit-mode .editable-cell.modified {
    background-color: #dbeafe;
}

/* New deal row highlight (persistent until clicked) */
.deal-row-new {
    background-color: #EFF6FF !important;  /* blue-50 */
    border-left: 3px solid #3B82F6;        /* blue-500 */
}

.deal-row-new:hover {
    background-color: #DBEAFE !important;  /* blue-100 */
}

/* Responsive table */
@media (max-width: 768px) {
    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* ============================================
   WhatsApp Web Style - Chat Manager (Light Theme)
   ============================================ */

/* Color Variables - Light Theme */
:root {
    --wa-bg-main: #f0f2f5;
    --wa-bg-sidebar: #ffffff;
    --wa-bg-chat: #efeae2;
    --wa-bg-panel: #f0f2f5;
    --wa-bg-bubble-mine: #d9fdd3;
    --wa-bg-bubble-other: #ffffff;
    --wa-bg-hover: #f5f6f6;
    --wa-bg-selected: #f0f2f5;
    --wa-bg-input: #ffffff;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-border: #e9edef;
    --wa-icon: #54656f;
    --wa-badge: #25d366;
    --wa-green: #25d366;
}

/* Background Colors */
.wa-bg-main { background-color: var(--wa-bg-main); }
.wa-bg-sidebar { background-color: var(--wa-bg-sidebar); }
.wa-bg-chat { background-color: var(--wa-bg-chat); }
.wa-bg-panel { background-color: var(--wa-bg-panel); }
.wa-bg-bubble-mine { background-color: var(--wa-bg-bubble-mine); }
.wa-bg-bubble-other { background-color: var(--wa-bg-bubble-other); }
.wa-bg-hover { background-color: var(--wa-bg-hover); }
.wa-bg-selected { background-color: var(--wa-bg-selected); }
.wa-bg-input { background-color: var(--wa-bg-input); }

/* Text Colors */
.wa-text-primary { color: var(--wa-text-primary); }
.wa-text-secondary { color: var(--wa-text-secondary); }
.wa-icon { color: var(--wa-icon); }

/* Border */
.wa-border { border-color: var(--wa-border); }

/* Badge */
.wa-badge { background-color: var(--wa-badge); }

/* Chat Room Item */
.chat-room-item {
    transition: background-color 0.15s ease;
}

.chat-room-item:hover {
    background-color: var(--wa-bg-hover);
}

.chat-room-item.selected {
    background-color: var(--wa-bg-selected);
}

/* Message Bubble Base */
.message-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* My Message (Right) */
.message-bubble-mine {
    background-color: var(--wa-bg-bubble-mine);
    border-top-right-radius: 0;
    margin-left: auto;
}

/* Other's Message (Left) */
.message-bubble-other {
    background-color: var(--wa-bg-bubble-other);
    border-top-left-radius: 0;
}

/* Message Bubble Tail - Mine (Right) */
.message-bubble-mine::before {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid var(--wa-bg-bubble-mine);
    border-top: 0px solid transparent;
    border-bottom: 13px solid transparent;
}

/* Message Bubble Tail - Other (Left) */
.message-bubble-other::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-right: 8px solid var(--wa-bg-bubble-other);
    border-top: 0px solid transparent;
    border-bottom: 13px solid transparent;
}

/* Message Time */
.message-time {
    font-size: 11px;
    color: var(--wa-text-secondary);
    margin-left: 4px;
    white-space: nowrap;
}

/* Read Checkmarks */
.message-check {
    color: var(--wa-text-secondary);
}

.message-check.read {
    color: #53bdeb;
}

/* Date Divider */
.date-divider {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--wa-text-secondary);
    padding: 5px 12px;
    border-radius: 7.5px;
    font-size: 12.5px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Search Input */
.wa-search-input {
    background-color: var(--wa-bg-panel);
    color: var(--wa-text-primary);
    border: 1px solid var(--wa-border);
    border-radius: 8px;
    padding: 8px 12px 8px 32px;
    font-size: 14px;
    width: 100%;
}

.wa-search-input::placeholder {
    color: var(--wa-text-secondary);
}

.wa-search-input:focus {
    outline: none;
}

/* Message Input */
.wa-message-input {
    background-color: var(--wa-bg-input);
    color: var(--wa-text-primary);
    border: 1px solid var(--wa-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 15px;
    width: 100%;
    resize: none;
    min-height: 42px;
    max-height: 150px;
}

.wa-message-input::placeholder {
    color: var(--wa-text-secondary);
}

.wa-message-input:focus {
    outline: none;
}

/* Avatar */
.wa-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    background-color: var(--wa-bg-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    color: var(--wa-text-secondary);
    flex-shrink: 0;
}

.wa-avatar-sm {
    width: 40px;
    height: 40px;
    font-size: 16px;
}

/* Scrollbar for chat manager */
.wa-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.wa-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.wa-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.wa-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Group Filter Chip */
.wa-chip {
    background-color: var(--wa-bg-panel);
    color: var(--wa-text-primary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border: 1px solid var(--wa-border);
}

.wa-chip:hover {
    background-color: var(--wa-bg-hover);
}

.wa-chip.active {
    background-color: var(--wa-green);
    color: #ffffff;
    border-color: var(--wa-green);
}

/* Dropdown */
.wa-dropdown {
    background-color: var(--wa-bg-input);
    border: 1px solid var(--wa-border);
    border-radius: 4px;
    color: var(--wa-text-primary);
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
}

.wa-dropdown:focus {
    outline: none;
    border-color: var(--wa-green);
}

/* Icon Button */
.wa-icon-btn {
    color: var(--wa-icon);
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.wa-icon-btn:hover {
    background-color: var(--wa-bg-hover);
}

/* Unread Badge */
.unread-badge {
    background-color: var(--wa-badge);
    color: #ffffff;
    font-size: 11px;
    font-weight: 500;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Chat Background Pattern (optional) */
.chat-bg-pattern {
    background-color: var(--wa-bg-chat);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d7db' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ===== Search Feature Styles ===== */

/* Search Result Item */
.search-result-item {
    transition: background-color 0.15s ease;
}

.search-result-item:hover {
    background-color: var(--wa-bg-hover);
}

/* Platform Badges */
.platform-badge-whatsapp {
    background-color: #dcfce7;
    color: #166534;
}

.platform-badge-kakao {
    background-color: #fef08a;
    color: #854d0e;
}

.platform-badge-kakao-biz {
    background-color: #fde047;
    color: #713f12;
}

.platform-badge-wechat {
    background-color: #d1fae5;
    color: #065f46;
}

.platform-badge-default {
    background-color: #e5e7eb;
    color: #374151;
}

/* Search Term Highlight */
.search-highlight {
    background-color: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
    color: inherit;
}

/* Message Highlight Animation (when navigating from search) */
.message-highlight {
    animation: message-highlight-pulse 3s ease-out;
}

@keyframes message-highlight-pulse {
    0% {
        background-color: #fef08a;
        box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.4);
    }
    70% {
        background-color: #fef08a;
        box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.2);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Line clamp for search results */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== AI Chatbot Styles ===== */

/* Search Mode Dropdown */
.search-mode-dropdown {
    background-color: var(--wa-bg-input);
    border: 1px solid var(--wa-border);
    border-radius: 8px;
    color: var(--wa-text-primary);
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    min-width: 100px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667781' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.search-mode-dropdown:focus {
    outline: none;
    border-color: var(--wa-green);
}

.search-mode-dropdown:hover {
    background-color: var(--wa-bg-hover);
}

/* AI Chat Background */
.ai-chat-bg {
    background-color: #e8e0d5;
    background-image: linear-gradient(135deg, #f5f0eb 0%, #e8e0d5 100%);
}

/* AI Message Bubble Base */
.ai-message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
}

/* User Message (Right) */
.ai-message-user {
    background-color: var(--wa-bg-bubble-mine);
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

/* AI Assistant Message (Left) */
.ai-message-assistant {
    background-color: #ffffff;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--wa-border);
}

/* AI Avatar */
.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--wa-text-secondary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* AI Message Bullet Points */
.ai-bullet {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0;
}

.ai-bullet::before {
    content: '•';
    color: var(--wa-text-secondary);
    font-weight: bold;
    flex-shrink: 0;
}

/* AI Message Bold Text */
.ai-message-bubble strong {
    font-weight: 600;
    color: var(--wa-text-primary);
}

/* AI Welcome Message */
.ai-welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--wa-text-secondary);
}

.ai-welcome-message svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

/* Clear Chat Button */
.ai-clear-btn {
    background-color: transparent;
    border: 1px solid var(--wa-border);
    color: var(--wa-text-secondary);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-clear-btn:hover {
    background-color: var(--wa-bg-hover);
    color: var(--wa-text-primary);
}

/* ============================================
   Message Status Animations
   ============================================ */

/* Sent checkmark fade-out animation */
.message-sent-check {
    transition: opacity 0.5s ease-out;
}

.message-sent-check.fade-out {
    opacity: 0;
}

/* Retry button hover animation */
.retry-btn {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.retry-btn:hover {
    animation: spin-once 0.5s ease-in-out;
}

@keyframes spin-once {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Status icon styles */
.status-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Pending status pulse animation (optional) */
.status-pending {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Supplier Tab Flash Notification
   ============================================ */

/* Flash animation for supplier tabs when new message arrives */
.tab-flash-notification {
    animation: tab-flash 1s ease-in-out infinite;
    position: relative;
}

@keyframes tab-flash {
    0%, 100% {
        background-color: #fef3c7; /* amber-100 */
        box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4);
    }
    50% {
        background-color: #fcd34d; /* amber-300 */
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.6);
    }
}

/* Ensure supplier tab buttons have relative positioning */
#supplier-tabs button {
    position: relative;
}

/* ============================================
   Chat Manager - Left Sidebar Compact Font Sizes
   ============================================ */

/* Chat Room Item - Compact Layout */
.chat-room-item {
    padding: 8px 12px !important;  /* Reduced padding */
}

/* Room Name - 11px */
.chat-room-item .wa-text-primary.font-medium {
    font-size: 11px !important;
    line-height: 1.3;
}

/* Last Time - 9px */
.chat-room-item .wa-text-secondary.text-xs {
    font-size: 9px !important;
}

/* Last Message Preview - 10px */
.chat-room-item .wa-text-secondary.text-sm {
    font-size: 10px !important;
    line-height: 1.3;
}

/* Avatar - Smaller size */
.chat-room-item .wa-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
}

/* Unread Badge - Smaller */
.chat-room-item .unread-badge {
    font-size: 9px;
    min-width: 15px;
    height: 15px;
    border-radius: 7.5px;
    padding: 0 4px;
}