/**
 * Cbran Provider - Provider Dashboard Styles
 *
 * @version 1.4.0
 * @description Custom styles for the new provider dashboard application.
 */

body:has(#cbran-provider-dashboard-app) {
    background-color: #f8fafc; /* bg-slate-50 */
    font-family: 'Inter', sans-serif;
}

/* --- Base Animations & Transitions --- */
.animate-fade-in { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-out { animation: fadeOut 0.5s ease-in-out forwards; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

.card-hover-effect { transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; }
.card-hover-effect:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); }
.button-active-effect:active { transform: scale(0.97); transition: transform 0.1s ease-in; }

/* --- Notification Bell Pulse Animations --- */
.animate-pulse-normal { animation: pulse-normal 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse-normal { 50% { box-shadow: 0 0 0 8px rgba(236, 72, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); } }
.animate-pulse-urgent { animation: pulse-urgent 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse-urgent { 50% { box-shadow: 0 0 0 9px rgba(249, 115, 22, 0); } 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); } }
.animate-pulse-critical { animation: pulse-critical 1s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse-critical { 50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } }

/* --- Custom Scrollbar --- */
.notification-scroll::-webkit-scrollbar, .chat-scroll::-webkit-scrollbar { width: 5px; }
.notification-scroll::-webkit-scrollbar-track, .chat-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.notification-scroll::-webkit-scrollbar-thumb, .chat-scroll::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.notification-scroll::-webkit-scrollbar-thumb:hover, .chat-scroll::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* =================================================================== */
/* =================== IMPROVED CHAT MODAL STYLES ==================== */
/* =================================================================== */

.chat-modal-container {
    position: relative;
    background: white;
    border-radius: 1rem;
    width: 100%;
    max-width: 28rem;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: chatModalSlideIn 0.3s ease-out;
    z-index: 10001;
}

@keyframes chatModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: white;
    border-radius: 1rem 1rem 0 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar-large {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f3f4f6;
}

.chat-header-details {
    display: flex;
    flex-direction: column;
}

.chat-header-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.25;
}

.chat-header-subtitle {
    margin: 0;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.25;
}

.chat-close-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-close-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.chat-privacy-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    font-size: 0.75rem;
    color: #92400e;
    flex-shrink: 0;
}

.chat-privacy-notice i {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
}

.chat-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 200px;
    max-height: calc(85vh - 280px);
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.chat-history-container::-webkit-scrollbar {
    width: 6px;
}

.chat-history-container::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.chat-history-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-history-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.chat-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: #6b7280;
    flex: 1;
    min-height: 200px;
}

.chat-loading-state p {
    margin: 0;
}

.chat-loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e5e7eb;
    border-top-color: #db2777;
    border-radius: 50%;
    animation: chatSpinner 0.8s linear infinite;
    margin-bottom: 0.5rem;
}

@keyframes chatSpinner {
    to { transform: rotate(360deg); }
}

.chat-message {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
    animation: chatMessageSlideIn 0.3s ease-out;
}

@keyframes chatMessageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.client {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
    position: relative;
}

.chat-message.client .chat-message-bubble {
    background: #db2777;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.provider .chat-message-bubble {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message-content {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.chat-message-time {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.chat-message.client .chat-message-time {
    text-align: right;
}

.chat-error-alert {
    padding: 0.75rem 1rem;
    margin: 0.5rem 1rem;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    color: #991b1b;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.chat-modal-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    background: white;
    border-radius: 0 0 1rem 1rem;
    flex-shrink: 0;
}

.chat-send-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-input-wrapper {
    position: relative;
    flex: 1;
}

.chat-message-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-bottom: 1.75rem;
    border: 1px solid #d1d5db;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    background: #f9fafb;
    transition: all 0.2s;
}

.chat-message-input:focus {
    outline: none;
    border-color: #db2777;
    background: white;
    box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.1);
}

.chat-char-count {
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    font-size: 0.65rem;
    color: #9ca3af;
}

.chat-send-btn {
    padding: 0.75rem;
    background: #db2777;
    color: white;
    border: none;
    border-radius: 50%;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #be185d;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* Chat container when inside a tab (not modal) */
.chat-container {
    display: flex !important;
    flex-direction: column !important;
    height: 70vh !important;
    min-height: 70vh;
    background: white;
    border-radius: 1rem;
    overflow: hidden;
}

.chat-container .chat-modal-header {
    border-radius: 1rem 1rem 0 0;
    margin: 0;
    padding: 1rem 1.25rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

.chat-container .chat-privacy-notice {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
}

.chat-container .chat-history-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.chat-container .chat-modal-footer {
    border-radius: 0 0 1rem 1rem;
    margin: 0;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-container .chat-error-alert {
    margin: 0.5rem 1rem;
}

/* Ensure proper spacing inside main-tab-pane */
.main-tab-pane .chat-container {
    width: 100%;
    margin: 0;
}

.main-tab-pane {
    padding: 1rem;
}

/* Image Preview Styles */
.chat-image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    max-height: 200px;
    overflow-y: auto;
}

.chat-image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid #e5e7eb;
    background: white;
}

.chat-image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-image-preview-item .chat-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dc2626;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.2s;
}

.chat-image-preview-item .chat-preview-remove:hover {
    background: #b91c1c;
    transform: scale(1.1);
}

.chat-image-preview-item .chat-preview-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-image-preview-item .chat-preview-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #991b1b;
    font-size: 0.65rem;
    text-align: center;
    padding: 0.25rem;
}

.chat-attach-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-attach-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
    .chat-modal-container {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 1rem 1rem 0 0;
    }
    
    .chat-message-bubble {
        max-width: 85%;
    }
    
    .chat-container {
        height: 60vh !important;
    }
}

/* --- Sliding Toggle/Pill Selector --- */
#cbran-provider-dashboard-app .toggle-container { 
    position: relative; 
    display: flex; 
    width: 100%; 
    background-color: #e5e7eb;
    border-radius: 9999px;
    padding: 4px;
}
#cbran-provider-dashboard-app .toggle-container {
    z-index: 1;
    /* Create a stacking context */
    isolation: isolate;
}
#cbran-provider-dashboard-app .toggle-glider { 
    position: absolute; 
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    background-color: #ffffff !important; 
    border-radius: 9999px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
    transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1); 
    z-index: 2 !important; /* Above the gray background but below buttons */
    pointer-events: none; /* Allow clicks to pass through to buttons */
}
#cbran-provider-dashboard-app .toggle-button { 
    position: relative; 
    z-index: 10 !important; /* Above everything to remain clickable */
    background-color: transparent !important; /* Ensure transparent background */ 
    flex: 1; 
    text-align: center; 
    color: #4b5563; 
    transition: color 0.4s ease; 
    border: none; 
    cursor: pointer; 
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}
#cbran-provider-dashboard-app .toggle-button.active { 
    color: #db2777;
}

/* --- Accordion --- */
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.5s cubic-bezier(0, 1, 0, 1); }
.accordion-content.open { max-height: 2000px; transition: max-height 1s ease-in-out; }

/* --- Task Card & Urgency Bar --- */
.scroll-container { overflow: hidden; white-space: nowrap; display: flex; align-items: center; }
.scrolling-text.animate-scroll { padding-left: 100%; animation: cbran-marquee-scroll 15s linear infinite; }
@keyframes cbran-marquee-scroll { 0% { transform: translateX(0%); } 100% { transform: translateX(-200%); } }
.urgency-bar { position: relative; overflow: hidden; }
.urgency-bar::after { content: ''; position: absolute; top: 0; left: 0; width: 150%; height: 100%; animation-name: cbran-wave-effect; animation-timing-function: linear; animation-iteration-count: infinite; transform: translateX(-150%); }
@keyframes cbran-wave-effect { 0% { transform: translateX(-150%); } 100% { transform: translateX(150%); } }
.wave-urgent::after { animation-duration: 2s; background: linear-gradient(90deg, transparent, rgba(185, 28, 28, 0.2), transparent); }
.wave-soon::after { animation-duration: 3.5s; background: linear-gradient(90deg, transparent, rgba(194, 65, 12, 0.2), transparent); }
.wave-today::after { animation-duration: 5s; background: linear-gradient(90deg, transparent, rgba(22, 101, 52, 0.15), transparent); }
.wave-late::after { animation-duration: 1s; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent); z-index: 1; }
.wave-active::after { animation-duration: 4s; background: linear-gradient(90deg, transparent, rgba(147, 197, 253, 0.4), transparent); }
.status-late-bg { background-image: linear-gradient(to right, #ef4444, #dc2626); }
.status-active-bg { background-image: linear-gradient(to right, #60a5fa, #3b82f6); }
.status-urgent-bg { background-image: linear-gradient(to right, #fee2e2, #fecaca); }
.status-soon-bg { background-image: linear-gradient(to right, #ffedd5, #fed7aa); }
.status-today-bg { background-image: linear-gradient(to right, #dcfce7, #bbf7d0); }
.status-late-text, .status-active-text { color: #ffffff; }
.status-urgent-text { color: #b91c1c; }
.status-soon-text { color: #c2410c; }
.status-today-text { color: #166534; }

/* --- Modals --- */
.modal-overlay { transition: opacity 0.3s ease-in-out; }
.modal-content { transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out; }

/* --- Full Screen Views --- */
body:has(.fullscreen-view-active) {
    overflow: hidden;
}
#cbran-provider-dashboard-app.fullscreen-view-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f8fafc;
    z-index: 100000;
    overflow-y: auto;
    padding: 0 !important;
}

/* --- Chat Specific Styles --- */
.chat-bubble.provider {
    background-color: #db2777; /* pink-600 */
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.client {
    background-color: #ffffff;
    color: #1f2937; /* slate-800 */
    border-bottom-left-radius: 4px;
}
