/* NanoCRM - Admin Dashboard Styles */

/* Navigation */
.nav-link.active {
    background-color: rgba(59, 130, 246, 0.5);
}

/* Status badges */
.status-badge {
    @apply px-2 py-1 rounded-full text-xs font-medium;
}

.status-new {
    @apply bg-blue-100 text-blue-800;
}

.status-contacted {
    @apply bg-yellow-100 text-yellow-800;
}

.status-qualified {
    @apply bg-purple-100 text-purple-800;
}

.status-converted {
    @apply bg-green-100 text-green-800;
}

.status-lost {
    @apply bg-red-100 text-red-800;
}

.status-pending {
    @apply bg-gray-100 text-gray-800;
}

.status-confirmed {
    @apply bg-blue-100 text-blue-800;
}

.status-shipped {
    @apply bg-yellow-100 text-yellow-800;
}

.status-delivered {
    @apply bg-green-100 text-green-800;
}

.status-cancelled {
    @apply bg-red-100 text-red-800;
}

.payment-pending {
    @apply bg-yellow-100 text-yellow-800;
}

.payment-paid {
    @apply bg-green-100 text-green-800;
}

.payment-failed {
    @apply bg-red-100 text-red-800;
}

/* Fulfillment status */
.fulfillment-unfulfilled {
    @apply bg-gray-100 text-gray-600;
}

.fulfillment-shipped {
    @apply bg-purple-100 text-purple-800;
}

.fulfillment-delivered {
    @apply bg-green-100 text-green-800;
}

/* Table */
.table-row-hover:hover {
    @apply bg-gray-50;
}

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

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

/* Funnel visualization */
.funnel-step {
    position: relative;
}

.funnel-arrow {
    padding: 0 10px;
}

/* Modal animations */
.modal-enter {
    animation: modalEnter 0.2s ease-out;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 100;
    animation: slideIn 0.3s ease-out;
}

.toast-success {
    background-color: #10b981;
}

.toast-error {
    background-color: #ef4444;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #sidebar {
        width: 0;
        overflow: hidden;
        transition: width 0.3s ease;
    }

    #sidebar.open {
        width: 256px;
    }

    main {
        margin-left: 0 !important;
    }
}

/* Data table improvements */
table tbody tr {
    transition: background-color 0.15s ease;
}

table tbody tr:hover {
    background-color: #f9fafb;
}

/* Action buttons */
.action-btn {
    @apply p-2 rounded hover:bg-gray-100 transition;
}

.action-btn:hover {
    background-color: #f3f4f6;
}

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

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

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

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #d1d5db;
}

/* Chart container */
canvas {
    max-height: 300px;
}

/* Dashboard Tabs (Browser-like) */
.dashboard-tab {
    position: relative;
    transition: all 0.15s ease;
}

.dashboard-tab:not(.active) {
    background-color: #e5e7eb;
    border-color: transparent;
    opacity: 0.8;
}

.dashboard-tab:not(.active):hover {
    background-color: #f3f4f6;
    opacity: 1;
}

.dashboard-tab.active {
    z-index: 10;
}

.dashboard-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: white;
}

.dashboard-tab .tab-close {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.dashboard-tab:hover .tab-close {
    opacity: 1;
}

.dashboard-tab .tab-close:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Tab icon colors based on type */
.dashboard-tab[data-type="sales"] i { color: #10b981; }
.dashboard-tab[data-type="marketing"] i { color: #8b5cf6; }
.dashboard-tab[data-type="executive"] i { color: #3b82f6; }
.dashboard-tab[data-type="operations"] i { color: #f97316; }
.dashboard-tab[data-type="customer"] i { color: #ec4899; }
.dashboard-tab[data-type="blank"] i { color: #6b7280; }

/* Horizontal tab scrolling */
#dashboard-tabs-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#dashboard-tabs-container::-webkit-scrollbar {
    display: none;
}

/* ========================================
   WhatsApp Inbox Styles
   ======================================== */

/* Inbox Item */
.inbox-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.inbox-item:hover {
    background-color: #f9fafb;
}

.inbox-item.selected {
    background-color: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.inbox-item.unread {
    background-color: #fefce8;
}

.inbox-item.unread .contact-name {
    font-weight: 600;
}

/* Avatar */
.inbox-item-avatar {
    position: relative;
    flex-shrink: 0;
}

.inbox-item-avatar img,
.inbox-item-avatar .avatar-letter {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.inbox-item-avatar .avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: #22c55e;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content */
.inbox-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inbox-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-name {
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 12px;
    color: #9ca3af;
    flex-shrink: 0;
}

.inbox-item-preview {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-item-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* Status badges in inbox */
.inbox-item .status-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

.status-open {
    background-color: #dcfce7;
    color: #166534;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-resolved {
    background-color: #e0e7ff;
    color: #3730a3;
}

.status-closed {
    background-color: #f3f4f6;
    color: #4b5563;
}

.assigned-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #dbeafe;
    color: #1e40af;
}

.assigned-badge.unassigned {
    background-color: #fee2e2;
    color: #991b1b;
}

.tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Empty state */
.inbox-empty,
.inbox-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.inbox-empty i,
.inbox-error i {
    font-size: 48px;
    margin-bottom: 16px;
}

.inbox-error i {
    color: #ef4444;
}

/* ========================================
   Chat Panel Styles
   ======================================== */

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #f3f4f6;
}

/* Chat Message Container */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.chat-message.incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-message.outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

/* Sender Label */
.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    padding-left: 4px;
}

.chat-message.incoming .message-sender {
    color: #7c3aed;
}

.chat-message.outgoing .message-sender {
    color: #059669;
}

/* Message Bubble */
.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-message.incoming .message-bubble {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.outgoing .message-bubble {
    background-color: #dcfce7;
    border: 1px solid #bbf7d0;
    border-bottom-right-radius: 4px;
}

/* Message Content */
.message-text {
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    margin: 0;
    white-space: pre-wrap;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    font-size: 11px;
    color: #9ca3af;
}

.message-time {
    color: #9ca3af;
}

.message-status {
    font-size: 12px;
}

.message-status i {
    font-size: 12px;
}

/* Message Types */
.message-image img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
}

.message-image .message-caption,
.message-video .message-caption {
    margin-top: 6px;
    font-size: 14px;
    color: #1f2937;
}

.message-video video {
    max-width: 100%;
    border-radius: 8px;
}

.message-audio audio {
    width: 100%;
    min-width: 200px;
}

.message-document .document-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(0,0,0,0.05);
    border-radius: 8px;
    text-decoration: none;
    color: #1f2937;
}

.message-document .document-link:hover {
    background-color: rgba(0,0,0,0.1);
}

.message-sticker img {
    max-width: 150px;
}

.message-location a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #3b82f6;
    text-decoration: none;
}

.message-location a:hover {
    text-decoration: underline;
}

.message-template {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #6b7280;
}

.message-template i {
    color: #9ca3af;
}

/* Chat Header */
#chat-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.chat-header-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-avatar .avatar-letter {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info .contact-name {
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    font-size: 16px;
}

.chat-header-info .contact-phone {
    font-size: 13px;
    color: #6b7280;
    display: block;
}

.session-active {
    font-size: 11px;
    color: #22c55e;
    display: inline-block;
    margin-left: 8px;
}

.session-expired {
    font-size: 11px;
    color: #f59e0b;
    display: inline-block;
    margin-left: 8px;
}

.whatsapp-account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #25D366;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-actions .btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.chat-header-actions .btn-icon:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

/* Dropdown in header */
.chat-header-actions .dropdown {
    position: relative;
}

.chat-header-actions .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 160px;
    z-index: 100;
}

.chat-header-actions .dropdown:hover .dropdown-menu {
    display: block;
}

.chat-header-actions .dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
}

.chat-header-actions .dropdown-menu a:hover {
    background-color: #f3f4f6;
}

/* Date separator */
.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    font-size: 12px;
    color: #6b7280;
}

/* Empty state when no messages */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    padding: 48px;
}

.chat-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    color: #d1d5db;
}

.chat-empty p {
    margin: 0;
    font-size: 14px;
}

/* No conversation selected */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
}

.chat-empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    color: #d1d5db;
}

/* Loading state */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: #9ca3af;
}

/* Typing indicator */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    align-self: flex-start;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.typing-text {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

/* Chat Input */
#chat-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}

#chat-message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#chat-message-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

/* ========================================
   Bounce Animation for WhatsApp Button
   ======================================== */

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.bounce-animation {
    animation: bounce 2s infinite;
}

.bounce-animation:hover {
    animation: none;
}

/* ========================================
   Kanban Board Styles
   ======================================== */

#kanban-board {
    display: flex;
    gap: 16px;
    padding: 16px;
    overflow-x: auto;
    min-height: calc(100vh - 200px);
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.kanban-column-header {
    padding: 16px;
    border-top: 4px solid var(--stage-color, #6b7280);
    border-radius: 12px 12px 0 0;
    background: white;
}

.kanban-column-header .column-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-column-header .stage-name {
    font-weight: 600;
    color: #1f2937;
}

.kanban-column-header .card-count {
    background: #e5e7eb;
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-column-header .column-value {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.kanban-column-body {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    min-height: 100px;
}

.kanban-column-body.drag-over {
    background: #e0f2fe;
    border: 2px dashed #3b82f6;
    border-radius: 8px;
}

.kanban-column-footer {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
}

.kanban-column-footer .btn-add-card {
    width: 100%;
    padding: 8px;
    color: #6b7280;
    font-size: 13px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.kanban-column-footer .btn-add-card:hover {
    background: #e5e7eb;
    color: #374151;
}

.kanban-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: grab;
    transition: all 0.2s;
    border: 1px solid #e5e7eb;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.kanban-card .card-header {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.kanban-card .card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.kanban-card .card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kanban-card .card-title-wrap {
    flex: 1;
    min-width: 0;
}

.kanban-card .card-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card .card-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin: 2px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card .card-value {
    font-weight: 600;
    color: #059669;
    font-size: 14px;
    margin-bottom: 8px;
}

.kanban-card .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.kanban-card .card-tags .tag {
    font-size: 10px;
    padding: 2px 6px;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 4px;
}

.kanban-card .card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
}

.kanban-card .assigned-to {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kanban-card.priority-high {
    border-left: 3px solid #ef4444;
}

.kanban-card.priority-medium {
    border-left: 3px solid #f59e0b;
}

.kanban-card.priority-low {
    border-left: 3px solid #10b981;
}

/* Kanban stats bar */
#kanban-stats {
    display: flex;
    gap: 24px;
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

#kanban-stats .stat {
    display: flex;
    flex-direction: column;
}

#kanban-stats .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

#kanban-stats .stat-label {
    font-size: 12px;
    color: #6b7280;
}

/* Phone number badge in inbox */
.inbox-item .phone-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    white-space: nowrap;
}
