/**
 * WBA Filament Plugin Styles
 * WhatsApp Business API integration for Filament
 */

/* Base variables */
:root {
    --wba-whatsapp-green: #25d366;
    --wba-whatsapp-dark-green: #075e54;
    --wba-whatsapp-light-green: #dcf8c6;
    --wba-chat-bg: #e5ddd5;
    --wba-bubble-sent: #dcf8c6;
}

/* Dark mode variables */
.dark {
    --wba-chat-bg: #0b141a;
    --wba-bubble-sent: #056162;
}

/* WhatsApp styled preview container */
.wba-preview-container {
    background-color: var(--wba-chat-bg);
    border-radius: 8px;
    padding: 16px;
}

/* Message bubble styling */
.wba-message-bubble {
    background-color: var(--wba-bubble-sent);
    border-radius: 8px;
    border-top-right-radius: 0;
    padding: 8px 12px;
    max-width: 85%;
    margin-left: auto;
    position: relative;
}

/* Status badges */
.wba-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

/* Template parameter styling */
.wba-parameter-highlight {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px dashed rgba(59, 130, 246, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    color: #3b82f6;
}

.dark .wba-parameter-highlight {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Live preview animation */
.wba-preview-updating {
    animation: wba-pulse 1s ease-in-out infinite;
}

@keyframes wba-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Template card styles */
.wba-template-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s;
}

.wba-template-card:hover {
    border-color: var(--wba-whatsapp-green);
    box-shadow: 0 0 0 1px var(--wba-whatsapp-green);
}

.dark .wba-template-card {
    border-color: #374151;
}

.dark .wba-template-card:hover {
    border-color: var(--wba-whatsapp-green);
}

/* Phone input styles */
.wba-phone-input {
    direction: ltr;
    text-align: left;
}

/* RTL support for Arabic */
[dir="rtl"] .wba-phone-input {
    direction: ltr;
    text-align: left;
}

/* Timeline styles */
.wba-timeline {
    position: relative;
    padding-left: 24px;
}

.wba-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e5e7eb;
}

.dark .wba-timeline::before {
    background-color: #374151;
}

.wba-timeline-item {
    position: relative;
    padding-bottom: 16px;
}

.wba-timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #9ca3af;
}

.wba-timeline-item.wba-status-sent::before {
    background-color: #3b82f6;
}

.wba-timeline-item.wba-status-delivered::before {
    background-color: #10b981;
}

.wba-timeline-item.wba-status-read::before {
    background-color: #06b6d4;
}

.wba-timeline-item.wba-status-failed::before {
    background-color: #ef4444;
}

/* Scheduling info box */
.wba-scheduling-info {
    background-color: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dark .wba-scheduling-info {
    background-color: rgba(254, 243, 199, 0.1);
    border-color: rgba(252, 211, 77, 0.3);
}

/* Cancel window indicator */
.wba-cancel-window {
    background-color: #dbeafe;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark .wba-cancel-window {
    background-color: rgba(219, 234, 254, 0.1);
}

.wba-cancel-window.wba-expired {
    background-color: #f3f4f6;
    color: #6b7280;
}

.dark .wba-cancel-window.wba-expired {
    background-color: rgba(243, 244, 246, 0.1);
}

/* Sync indicator */
.wba-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
}

.wba-sync-indicator.wba-syncing {
    color: #3b82f6;
}

.wba-sync-indicator.wba-syncing svg {
    animation: spin 1s linear infinite;
}

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

/* Error state styling */
.wba-error-details {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
}

.dark .wba-error-details {
    background-color: rgba(254, 242, 242, 0.1);
    border-color: rgba(254, 202, 202, 0.3);
}

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

.dark .wba-empty-state {
    color: #9ca3af;
}

.wba-empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

/* Template body preview in SendMessage page */
.wba-template-body-preview {
    padding: 12px;
    background-color: #f9fafb;
    border-radius: 8px;
    font-size: 14px;
    white-space: pre-wrap;
    color: #374151;
}

.dark .wba-template-body-preview {
    background-color: #1f2937;
    color: #e5e7eb;
}

/* ========================================
   Chat Center Styles
   ======================================== */

/* Chat Center Layout */
.wba-chat-layout {
    display: grid;
    gap: 1.5rem;
    min-height: calc(100vh - 12rem);
}

@media (min-width: 1024px) {
    .wba-chat-layout {
        grid-template-columns: 360px minmax(0, 1fr);
    }
}

/* Chat Center Container */
.wba-chat-section {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    border: 1px solid rgb(0 0 0 / 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 12rem);
    position: relative;
}

.dark .wba-chat-section {
    background-color: rgb(17 24 39);
    border-color: rgb(255 255 255 / 0.1);
}

/* Chat Header */
.wba-chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgb(229 231 235);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wba-chat-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.dark .wba-chat-header {
    border-bottom-color: rgb(255 255 255 / 0.1);
}

.wba-chat-header-title {
    font-size: 1rem;
    font-weight: 600;
    color: rgb(3 7 18);
}

.dark .wba-chat-header-title {
    color: #ffffff;
}

/* Chat List */
.wba-chat-list {
    overflow-y: auto;
}

.wba-chat-list-divider {
    border-color: rgb(229 231 235);
}

.dark .wba-chat-list-divider {
    border-color: rgb(255 255 255 / 0.1);
}

/* Chat Item */
.wba-chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    width: 100%;
    text-align: start;
    transition: background-color 0.15s;
    border-bottom: 1px solid rgb(229 231 235);
}

.dark .wba-chat-item {
    border-bottom-color: rgb(255 255 255 / 0.1);
}

.wba-chat-item:hover {
    background-color: rgb(249 250 251);
}

.dark .wba-chat-item:hover {
    background-color: rgb(255 255 255 / 0.05);
}

.wba-chat-item.selected {
    background-color: rgb(255 251 235);
}

.dark .wba-chat-item.selected {
    background-color: rgb(251 191 36 / 0.1);
}

/* Avatar */
.wba-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
    background-color: rgb(243 244 246);
    color: rgb(75 85 99);
}

.dark .wba-avatar {
    background-color: rgb(255 255 255 / 0.1);
    color: rgb(209 213 219);
}

.wba-avatar-primary {
    background-color: rgb(254 243 199);
    color: rgb(180 83 9);
}

.dark .wba-avatar-primary {
    background-color: rgb(251 191 36 / 0.2);
    color: rgb(251 191 36);
}

/* Chat Info */
.wba-chat-name {
    font-weight: 500;
    color: rgb(3 7 18);
}

.dark .wba-chat-name {
    color: #ffffff;
}

.wba-chat-preview {
    font-size: 0.875rem;
    color: rgb(107 114 128);
}

.dark .wba-chat-preview {
    color: rgb(156 163 175);
}

.wba-chat-time {
    font-size: 0.75rem;
    color: rgb(107 114 128);
}

.dark .wba-chat-time {
    color: rgb(156 163 175);
}

/* Messages Area */
.wba-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: rgb(249 250 251);
}

.dark .wba-messages-area {
    background-color: rgb(3 7 18);
}

/* Message Bubbles */
.wba-message {
    max-width: 75%;
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.wba-message-outgoing {
    background-color: rgb(251 191 36);
    color: #ffffff;
    border-end-start-radius: 0;
}

.wba-message-incoming {
    background-color: #ffffff;
    color: rgb(3 7 18);
    border: 1px solid rgb(0 0 0 / 0.05);
    border-end-end-radius: 0;
}

.dark .wba-message-incoming {
    background-color: rgb(31 41 55);
    color: #ffffff;
    border-color: rgb(255 255 255 / 0.1);
}

.wba-message-time {
    font-size: 0.6875rem;
    margin-top: 0.375rem;
}

.wba-message-outgoing .wba-message-time {
    color: rgb(255 255 255 / 0.7);
}

.wba-message-incoming .wba-message-time {
    color: rgb(156 163 175);
}

/* Message Input Area */
.wba-message-input-area {
    padding: 1rem;
    border-top: 1px solid rgb(229 231 235);
    background-color: #ffffff;
}

.dark .wba-message-input-area {
    border-top-color: rgb(255 255 255 / 0.1);
    background-color: rgb(17 24 39);
}

/* Empty State */
.wba-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2.5rem;
    text-align: center;
}

.wba-chat-empty-icon {
    width: 4rem;
    height: 4rem;
    padding: 1rem;
    border-radius: 9999px;
    background-color: rgb(243 244 246);
    color: rgb(156 163 175);
    margin-bottom: 1rem;
}

.dark .wba-chat-empty-icon {
    background-color: rgb(255 255 255 / 0.1);
    color: rgb(107 114 128);
}

.wba-chat-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgb(3 7 18);
    margin-bottom: 0.5rem;
}

.dark .wba-chat-empty-title {
    color: #ffffff;
}

.wba-chat-empty-text {
    font-size: 0.875rem;
    color: rgb(107 114 128);
}

.dark .wba-chat-empty-text {
    color: rgb(156 163 175);
}

/* Loading Overlay */
.wba-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgb(255 255 255 / 0.8);
    backdrop-filter: blur(4px);
}

.dark .wba-loading-overlay {
    background-color: rgb(17 24 39 / 0.8);
}

.wba-loading-text {
    font-size: 0.875rem;
    color: rgb(75 85 99);
}

.dark .wba-loading-text {
    color: rgb(209 213 219);
}

/* Utility Classes */
.wba-flex {
    display: flex;
}

.wba-flex-1 {
    flex: 1;
}

.wba-flex-col {
    flex-direction: column;
}

.wba-flex-wrap {
    flex-wrap: wrap;
}

.wba-items-center {
    align-items: center;
}

.wba-items-end {
    align-items: flex-end;
}

.wba-justify-between {
    justify-content: space-between;
}

.wba-justify-start {
    justify-content: flex-start;
}

.wba-justify-end {
    justify-content: flex-end;
}

.wba-gap-1 {
    gap: 0.25rem;
}

.wba-gap-2 {
    gap: 0.5rem;
}

.wba-gap-3 {
    gap: 0.75rem;
}

.wba-gap-4 {
    gap: 1rem;
}

.wba-space-y-1 > * + * {
    margin-top: 0.25rem;
}

.wba-space-y-4 > * + * {
    margin-top: 1rem;
}

.wba-min-w-0 {
    min-width: 0;
}

.wba-shrink-0 {
    flex-shrink: 0;
}

.wba-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wba-text-center {
    text-align: center;
}

.wba-p-6 {
    padding: 1.5rem;
}

.wba-px-1 {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

/* ========================================
   WhatsApp Formatting Toolbar
   ======================================== */

.wba-formatting-toolbar {
    border-bottom: 1px solid rgb(229 231 235);
    padding-bottom: 0.5rem;
}

.dark .wba-formatting-toolbar {
    border-bottom-color: rgb(255 255 255 / 0.1);
}

.wba-format-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    background-color: transparent;
    color: rgb(107 114 128);
    font-size: 0.875rem;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
}

.wba-format-btn:hover:not(:disabled) {
    background-color: rgb(243 244 246);
    color: rgb(3 7 18);
}

.wba-format-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dark .wba-format-btn {
    color: rgb(156 163 175);
}

.dark .wba-format-btn:hover:not(:disabled) {
    background-color: rgb(255 255 255 / 0.1);
    color: #ffffff;
}

/* Format button styles */
.wba-format-bold {
    font-weight: 700;
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

.wba-format-italic {
    font-style: italic;
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

.wba-format-strike {
    text-decoration: line-through;
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

.wba-format-mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.75rem;
}

.wba-format-icon {
    width: 1rem;
    height: 1rem;
}

/* ------------------------------------------------------------------ */
/* Inline-HTML helpers: package-rendered notes, previews, and callouts.
   These strings must not rely on the host panel's compiled Tailwind
   utilities (themes only ship the classes they use — anything else
   leaves SVGs unsized and layouts unstyled).                          */
/* ------------------------------------------------------------------ */

.wba-inline-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: rgb(107 114 128);
}

.dark .wba-inline-note {
    color: rgb(156 163 175);
}

.wba-inline-note svg {
    width: 1rem;
    height: 1rem;
    flex: none;
}

.wba-inline-muted {
    color: rgb(156 163 175);
}

.wba-preview-card {
    padding: 1rem;
    border-radius: 0.5rem;
    background: rgb(240 253 244);
    border: 1px solid rgb(187 247 208);
}

.dark .wba-preview-card {
    background: rgb(20 83 45 / 0.2);
    border-color: rgb(22 101 52);
}

.wba-preview-card__row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.wba-preview-card__avatar {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: rgb(34 197 94);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wba-preview-card__avatar svg {
    width: 1.5rem;
    height: 1.5rem;
    color: #fff;
}

.wba-preview-card__text {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    white-space: pre-wrap;
}

.wba-callout {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wba-callout svg {
    flex: none;
}

.wba-callout--warning {
    background: rgb(254 252 232);
    border: 1px solid rgb(254 240 138);
    color: rgb(133 77 14);
}

.dark .wba-callout--warning {
    background: rgb(113 63 18 / 0.2);
    border-color: rgb(161 98 7);
    color: rgb(254 240 138);
}

.wba-callout--warning svg {
    width: 1.25rem;
    height: 1.25rem;
    color: rgb(234 179 8);
}

.wba-callout--success {
    background: rgb(240 253 244);
    border: 1px solid rgb(187 247 208);
}

.dark .wba-callout--success {
    background: rgb(20 83 45 / 0.2);
    border-color: rgb(22 101 52);
}

.wba-callout--success svg {
    width: 2rem;
    height: 2rem;
    color: rgb(34 197 94);
}

.wba-callout--success p {
    margin: 0;
}

.wba-callout__title {
    font-weight: 600;
    color: rgb(22 101 52);
}

.dark .wba-callout__title {
    color: rgb(187 247 208);
}

.wba-callout__meta {
    font-size: 0.875rem;
    color: rgb(22 163 74);
}

.dark .wba-callout__meta {
    color: rgb(134 239 172);
}
