/* ConnectDesk Frontend - Professional Chat Integration Platform Styles */

:root {
    --primary-color: #2563eb;
    --whatsapp-color: #059669;
    --facebook-color: #1877f2;
    --success-color: #10b981;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
}

/* Hero Section */
.hero-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.hero-pattern {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.1;
    background-image:
        radial-gradient(circle at 25% 25%, white 2px, transparent 2px),
        radial-gradient(circle at 75% 75%, white 2px, transparent 2px);
    background-size: 50px 50px;
}

.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.logo i {
    font-size: 1.75rem;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Hero Content */
.hero-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 6rem 1.5rem 4rem;
    position: relative;
    z-index: 10;
}

.hero-text {
    text-align: center;
    color: white;
    margin-bottom: 4rem;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.feature-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-8px);
}

.feature-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.whatsapp-icon {
    background: var(--whatsapp-color);
}

.facebook-icon {
    background: var(--facebook-color);
}

.integration-icon {
    background: var(--primary-color);
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--gray-900);
}

.feature-description {
    color: var(--gray-600);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Chat Widgets */
.chat-floating-buttons {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-floating-buttons.hidden {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
}

.chat-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    color: white;
    font-size: 1.25rem;
    position: relative;
}

.chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.whatsapp-trigger {
    background: var(--whatsapp-color);
}

.facebook-trigger {
    background: var(--facebook-color);
}

.chat-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-900);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: var(--gray-900);
}

.chat-trigger:hover .chat-tooltip {
    opacity: 1;
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    height: 540px;
    background: linear-gradient(145deg, #ffffff 0%, #f6f8fb 60%, #eef2f7 100%);
    border-radius: 20px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.6),
        0 1px 0 rgba(17, 24, 39, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.7);
    display: none;
    flex-direction: column;
    z-index: 1100;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    backdrop-filter: blur(14px);
    position: fixed;
}

.chat-widget::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(120% 140% at 20% 10%, rgba(37, 99, 235, 0.05), transparent 40%),
        radial-gradient(130% 120% at 90% 80%, rgba(24, 119, 242, 0.05), transparent 45%);
    pointer-events: none;
}

.chat-widget.active {
    display: flex;
}

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

.chat-header {
    padding: 1.1rem 1.4rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.whatsapp-header {
    background: linear-gradient(120deg, #059669 0%, #0ea672 55%, #0fb981 100%);
}

.facebook-header {
    background: linear-gradient(120deg, #1877f2 0%, #3a7bfa 55%, #4d8bff 100%);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.chat-info {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.chat-status {
    font-size: 0.82rem;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.35rem;
    background:
        linear-gradient(180deg, #f5f7fb 0%, #e9edf5 100%),
        radial-gradient(90% 40% at 10% 10%, rgba(37, 99, 235, 0.05), transparent 60%),
        radial-gradient(80% 45% at 90% 20%, rgba(24, 119, 242, 0.04), transparent 55%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    background: #ffffff;
    padding: 1.35rem;
    border-radius: 14px;
    text-align: center;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.06),
        0 1px 0 rgba(255, 255, 255, 0.7);
}

.welcome-title {
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.welcome-text {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.message-bubble {
    max-width: 80%;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.message-sent {
    align-self: flex-end;
    color: white;
    border-bottom-right-radius: 10px;
}

.message-received {
    align-self: flex-start;
    background: #ffffff;
    color: var(--gray-800);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-bottom-left-radius: 10px;
}

.whatsapp-sent {
    background: linear-gradient(135deg, #0aa36c 0%, #0cbf7d 100%);
}

.facebook-sent {
    background: linear-gradient(135deg, #2f7cf8 0%, #5a95ff 100%);
}

.message-time {
    font-size: 0.72rem;
    opacity: 0.75;
    margin-top: 0.35rem;
    text-align: right;
}

.chat-input-container {
    padding: 1.3rem 1.4rem 1.4rem;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: #ffffff;
    border-radius: 16px;
    padding: 0.8rem 0.95rem;
    transition: all 0.2s;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.chat-input-wrapper:focus-within {
    background: #f8fbff;
    box-shadow:
        0 0 0 1px rgba(37, 99, 235, 0.08),
        0 12px 35px rgba(37, 99, 235, 0.12);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.9rem;
    resize: none;
    max-height: 80px;
    min-height: 22px;
}

.chat-send-btn {
    background: linear-gradient(135deg, #2563eb 0%, #4f8bff 100%);
    border: none;
    color: white;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.55rem 0.65rem;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
    opacity: 0.7;
    transform: translateY(0);
}

.chat-send-btn:hover,
.chat-send-btn.active {
    opacity: 1;
    transform: translateY(-1px);
}

/* Typing Indicator (Enhanced) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 12px;
    margin: 0.5rem 0;
    max-width: 150px;
    border: 1px solid var(--gray-200);
    animation: slideUp 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 0.125rem;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Error Message */
.error-message {
    color: #dc2626;
    text-align: center;
    padding: 0.75rem;
    font-size: 0.8rem;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 8px;
    margin: 0.5rem 0;
    animation: slideUp 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .hero-features {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .nav-links {
        display: none;
    }

    .chat-widget {
        width: calc(100vw - 2rem);
        height: 70vh;
        right: 1rem;
        bottom: 5rem;
    }

    .chat-floating-buttons {
        right: 1rem;
        bottom: 1.5rem;
    }

    .hero-content {
        padding: 4rem 1rem 2rem;
    }

    .nav-content {
        padding: 0 1rem;
        height: 60px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo i {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .chat-trigger {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }
}

/* Animation for message entry */
.message-enter {
    animation: messageSlide 0.3s ease-out;
}

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

/* Scroll behavior */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

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

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: slideIn 0.3s ease-out;
}

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

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

.modal-header h3 {
    margin: 0;
    color: var(--gray-900);
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input:invalid {
    border-color: #dc2626;
}

.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.form-footer p {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.form-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-header,
    .modal-body {
        padding: 1.5rem;
    }

    .modal-header h3 {
        font-size: 1.25rem;
    }
}

/* Focus states for accessibility */
.chat-trigger:focus,
.chat-close:focus,
.chat-send-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.nav-link:focus,
.btn-primary:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --gray-400: #6b7280;
        --gray-500: #4b5563;
        --gray-600: #374151;
    }
}

/* User Authentication Styles */
.user-auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.guest-auth-section {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.user-email {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.user-actions {
    position: relative;
}

.user-menu-btn {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--gray-200);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    animation: menuSlide 0.2s ease-out;
}

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

.user-menu-header {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.user-menu-name {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.user-menu-email {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.user-menu-phone {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.user-menu-divider {
    height: 1px;
    background: var(--gray-200);
}

.user-menu-item {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.user-menu-item:hover {
    background: var(--gray-50);
}

.logout-btn {
    color: #dc2626;
}

.logout-btn:hover {
    background: rgba(220, 38, 38, 0.05);
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary-color);
    padding: 1rem 1.25rem;
    min-width: 300px;
    z-index: 1002;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-out;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left-color: var(--success-color);
}

.notification-error {
    border-left-color: #dc2626;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notification-content i {
    font-size: 1.25rem;
    color: var(--success-color);
}

.notification-success .notification-content i {
    color: var(--success-color);
}

.notification-error .notification-content i {
    color: #dc2626;
}

/* Mobile responsiveness for user auth */
@media (max-width: 768px) {
    .user-auth-section,
    .guest-auth-section {
        display: flex;
    }

    .user-details {
        display: none;
    }

    .user-menu {
        right: -10px;
        min-width: 180px;
    }

    .notification {
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
