/* Patel Law Chat Widget */

/* ================================
   Brand Tokens
   ================================ */
.plc-widget {
    --pc-primary: #7A1332;
    --pc-primary-dark: #5C0F26;
    --pc-primary-hover: #5E0E26;
    --pc-accent: #F5821F;
    --pc-accent-hover: #D97218;
    --pc-accent-soft: rgba(245, 130, 31, 0.12);
    --pc-bg: #f3f4f8;
    --pc-surface: #ffffff;
    --pc-surface-soft: #f9f9fb;
    --pc-border: #e8eaf0;
    --pc-text: #1f2430;
    --pc-text-muted: #6d7380;
    --pc-success: #2bb673;
    --pc-shadow: 0 20px 45px rgba(18, 28, 45, 0.18);
    --pc-shadow-btn: 0 12px 24px rgba(245, 130, 31, 0.3);
    --pc-radius: 22px;
    --pc-radius-sm: 12px;
    --pc-radius-pill: 9999px;
    --pc-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --pc-font: 'Open Sans', sans-serif;
    --pc-font-heading: 'Raleway', sans-serif;
    --pc-text-base: 16px;
    --pc-text-sm: 13px;
    --pc-text-xs: 11px;

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2147483647;
    font-family: var(--pc-font);
    font-size: var(--pc-text-base);
    line-height: 1.55;
    color: var(--pc-text);
    pointer-events: none;
}

.plc-widget > * {
    pointer-events: auto;
}

/* ================================
   Reset
   ================================ */
.plc-widget,
.plc-widget *,
.plc-widget *::before,
.plc-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ================================
   FAB - Modern Floating Button
   ================================ */
.plc-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    height: 52px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff8b2c 0%, #f57a1f 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 22px rgba(245, 122, 31, 0.28);
    transition: transform var(--pc-transition), box-shadow var(--pc-transition), opacity var(--pc-transition);
    z-index: 2147483647;
    padding: 0 18px 0 14px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    animation: plc-fab-pulse 2.2s ease-in-out infinite;
    overflow: visible;
    gap: 10px;
}

.plc-fab svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    flex-shrink: 0;
}

.plc-fab-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    line-height: 1;
    font-family: var(--pc-font);
}

.plc-fab:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 14px 26px rgba(245, 122, 31, 0.34);
    animation: none;
}

.plc-fab:active {
    transform: scale(0.97);
}

.plc-fab:focus-visible {
    outline: 3px solid var(--pc-primary);
    outline-offset: 3px;
}

.plc-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.plc-fab.is-open {
    transform: scale(0);
    pointer-events: none;
    animation: none;
}

/* ================================
   Window
   ================================ */
.plc-window {
    position: fixed;
    bottom: 102px;
    right: 24px;
    width: 480px;
    height: 700px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: var(--pc-surface);
    border-radius: 26px;
    box-shadow: var(--pc-shadow);
    border: 1px solid rgba(122, 19, 50, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    z-index: 2147483646;
}

.plc-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ================================
   Header
   ================================ */
.plc-header {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-dark) 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-radius: 26px 26px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.plc-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.plc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.plc-avatar-text {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    line-height: 1;
}

.plc-avatar-text--sm {
    font-size: 10px;
}

.plc-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plc-title {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--pc-font-heading);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.plc-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.88);
}

.plc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pc-success);
    flex-shrink: 0;
    animation: plc-dot-blink 2s ease-in-out infinite;
}

@keyframes plc-dot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.plc-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.plc-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--pc-transition), transform var(--pc-transition);
    flex-shrink: 0;
}

.plc-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: rotate(90deg);
}

.plc-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.plc-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.plc-new-chat {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--pc-transition), transform var(--pc-transition);
    flex-shrink: 0;
}

.plc-new-chat:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: rotate(90deg);
}

.plc-new-chat:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.plc-new-chat svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ================================
   Messages Area
   ================================ */
.plc-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #f7f7fa 0%, #f3f4f8 100%);
    scroll-behavior: smooth;
}

.plc-messages::-webkit-scrollbar {
    width: 5px;
}

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

.plc-messages::-webkit-scrollbar-thumb {
    background: rgba(123, 128, 143, 0.4);
    border-radius: 3px;
}

/* ================================
   Message
   ================================ */
.plc-msg {
    display: flex;
    gap: 8px;
    max-width: 82%;
    animation: plc-msg-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes plc-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.plc-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.plc-msg--assistant {
    align-self: flex-start;
}

.plc-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pc-primary) 0%, #8d1b3d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
    box-shadow: 0 6px 12px rgba(122, 19, 50, 0.16);
}

.plc-msg-avatar .plc-avatar-text {
    font-size: 10px;
}

/* ================================
   Bubble
   ================================ */
.plc-msg-body {
    display: flex;
    flex-direction: column;
}

.plc-msg-bubble {
    padding: 12px 14px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    letter-spacing: 0.01em;
}

.plc-msg--user .plc-msg-bubble {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-hover) 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 10px 16px rgba(122, 19, 50, 0.12);
}

.plc-msg--assistant .plc-msg-bubble {
    background: var(--pc-surface);
    color: var(--pc-text);
    border: 1px solid var(--pc-border);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 8px 16px rgba(16, 24, 40, 0.04);
}

/* ================================
   Quick Action Chips
   ================================ */
.plc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.plc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-hover) 100%);
    color: #fff;
    border: none;
    border-radius: var(--pc-radius-pill);
    font-size: 13px;
    font-family: var(--pc-font);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--pc-transition), transform var(--pc-transition), box-shadow var(--pc-transition);
    white-space: nowrap;
    line-height: 1.3;
    box-shadow: 0 10px 18px rgba(122, 19, 50, 0.14);
}

.plc-chip:hover {
    background: linear-gradient(135deg, var(--pc-primary-hover) 0%, var(--pc-primary) 100%);
    transform: translateY(-1px);
}

.plc-chip:active {
    transform: scale(0.97);
}

.plc-chip:focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 2px;
}

.plc-chip-icon {
    font-size: 12px;
    line-height: 1;
}

/* ================================
   Timestamp
   ================================ */
.plc-msg-time {
    font-size: 11px;
    color: var(--pc-text-muted);
    margin-top: 6px;
    padding: 0 2px;
    line-height: 1;
}

.plc-msg--user .plc-msg-time {
    text-align: right;
}

/* ================================
   Typing Indicator
   ================================ */
.plc-typing {
    display: none;
    padding: 0 16px 14px;
    align-items: flex-start;
    gap: 8px;
    background: linear-gradient(180deg, rgba(243, 244, 248, 0.82) 0%, rgba(243, 244, 248, 1) 100%);
}

.plc-typing.is-visible {
    display: flex;
}

.plc-typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pc-primary) 0%, #8d1b3d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.plc-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 8px 16px rgba(16, 24, 40, 0.04);
}

.plc-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pc-text-muted);
    animation: plc-bounce 1.4s infinite ease-in-out;
}

.plc-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.plc-typing-dot:nth-child(3) { animation-delay: 0.32s; }

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

/* ================================
   Input Area
   ================================ */
.plc-input-area {
    border-top: 1px solid var(--pc-border);
    background: var(--pc-surface);
    flex-shrink: 0;
    padding-bottom: 4px;
}

.plc-form {
    padding: 14px 16px 8px;
}

.plc-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pc-surface-soft);
    border: 1px solid var(--pc-border);
    border-radius: var(--pc-radius-pill);
    padding: 4px 6px 4px 16px;
    transition: border-color var(--pc-transition), box-shadow var(--pc-transition), transform var(--pc-transition);
}

.plc-input-wrap:focus-within {
    border-color: rgba(122, 19, 50, 0.4);
    box-shadow: 0 0 0 4px rgba(122, 19, 50, 0.06);
    transform: translateY(-1px);
}

.plc-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 16px;
    font-family: var(--pc-font);
    color: var(--pc-text);
    padding: 10px 0;
    outline: none;
    min-width: 0;
    line-height: 1.5;
}

.plc-input:focus,
.plc-input:focus-visible {
    outline: none;
    box-shadow: none;
}

.plc-input::placeholder {
    color: var(--pc-text-muted);
    font-size: 15px;
}

.plc-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-dark) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--pc-transition), transform var(--pc-transition), box-shadow var(--pc-transition);
    box-shadow: 0 10px 18px rgba(122, 19, 50, 0.22);
}

.plc-send:hover {
    background: linear-gradient(135deg, var(--pc-primary-hover) 0%, var(--pc-primary) 100%);
    transform: scale(1.04);
}

.plc-send:active {
    transform: scale(0.94);
}

.plc-send:focus-visible {
    outline: 3px solid var(--pc-primary);
    outline-offset: 2px;
}

.plc-send:disabled {
    background: #C4C0BC;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.plc-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ================================
   Disclaimer
   ================================ */
.plc-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--pc-text-muted);
    padding: 4px 18px 10px;
    line-height: 1.4;
}

/* ================================
   Chat Controls (Sound & Zoom)
   ================================ */
.plc-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px 8px;
    border-top: 1px solid var(--pc-border);
    background: linear-gradient(180deg, rgba(243, 244, 248, 0.5) 0%, rgba(243, 244, 248, 0.8) 100%);
    flex-wrap: wrap;
}

.plc-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    color: var(--pc-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pc-transition);
    padding: 0;
    flex-shrink: 0;
}

.plc-control-btn:hover {
    background: var(--pc-surface);
    color: var(--pc-primary);
    border-color: var(--pc-primary);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(122, 19, 50, 0.12);
}

.plc-control-btn:active {
    transform: scale(0.95);
}

.plc-control-btn:focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 2px;
}

.plc-control-btn.is-active {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-hover) 100%);
    color: #fff;
    border-color: var(--pc-primary);
    box-shadow: 0 6px 14px rgba(122, 19, 50, 0.18);
}

.plc-control-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.plc-zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text-muted);
    min-width: 38px;
    text-align: center;
    line-height: 1;
}

/* ================================
   Mobile
   ================================ */
@media (max-width: 480px) {
    .plc-fab {
        bottom: 16px;
        right: 16px;
        width: 60px;
        height: 60px;
        border-radius: 18px;
    }

    .plc-fab svg {
        width: 24px;
        height: 24px;
    }

    .plc-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }

    .plc-header {
        border-radius: 0;
    }

    .plc-messages {
        flex: 1 1 0;
        min-height: 0;
        padding: 16px 14px;
        gap: 14px;
    }

    .plc-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .plc-input-area {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .plc-form {
        padding: 12px 14px 8px;
    }

    .plc-msg {
        max-width: 88%;
    }

    .plc-msg-bubble {
        padding: 10px 13px;
        font-size: 14px;
    }

    .plc-disclaimer {
        padding: 4px 14px 8px;
        font-size: 10px;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .plc-window {
        width: 390px;
        height: 580px;
        max-height: calc(100vh - 120px);
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .plc-window {
        width: 480px;
        height: 700px;
        max-height: calc(100vh - 120px);
    }
}

/* ================================
   Reduced Motion
   ================================ */
@media (prefers-reduced-motion: reduce) {
    .plc-widget * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================
   High Contrast
   ================================ */
@media (forced-colors: active) {
    .plc-fab,
    .plc-send,
    .plc-close {
        border: 2px solid ButtonText;
    }

    .plc-msg-bubble {
        border: 1px solid ButtonText;
    }

    .plc-chip {
        border: 1px solid ButtonText;
    }
}

/* ================================
   Print
   ================================ */
@media print {
    .plc-widget {
        display: none !important;
    }
}

/* ================================
   Modal Overlay & Dialog
   ================================ */
.plc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 28, 45, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483648;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    padding: 20px;
}

.plc-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.plc-modal {
    background: var(--pc-surface);
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(18, 28, 45, 0.24);
    border: 1px solid rgba(122, 19, 50, 0.08);
    max-width: 380px;
    width: 100%;
    animation: plc-modal-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@keyframes plc-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.plc-modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--pc-border);
    background: linear-gradient(135deg, rgba(122, 19, 50, 0.02) 0%, rgba(245, 130, 31, 0.02) 100%);
}

.plc-modal-title {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--pc-font-heading);
    color: var(--pc-text);
    margin: 0;
    line-height: 1.3;
}

.plc-modal-body {
    padding: 20px 24px;
    color: var(--pc-text-muted);
    font-size: 15px;
    line-height: 1.6;
}

.plc-modal-body p {
    margin: 0;
}

.plc-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--pc-border);
    background: linear-gradient(135deg, rgba(122, 19, 50, 0.01) 0%, rgba(245, 130, 31, 0.01) 100%);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.plc-modal-btn {
    padding: 10px 20px;
    border-radius: var(--pc-radius-pill);
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--pc-font);
    cursor: pointer;
    transition: background var(--pc-transition), transform var(--pc-transition), box-shadow var(--pc-transition);
    line-height: 1.4;
    white-space: nowrap;
}

.plc-modal-btn:hover {
    transform: translateY(-1px);
}

.plc-modal-btn:active {
    transform: scale(0.98);
}

.plc-modal-btn:focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 2px;
}

.plc-modal-btn--primary {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-hover) 100%);
    color: #fff;
    box-shadow: 0 10px 18px rgba(122, 19, 50, 0.14);
}

.plc-modal-btn--primary:hover {
    background: linear-gradient(135deg, var(--pc-primary-hover) 0%, var(--pc-primary) 100%);
}

.plc-modal-btn--secondary {
    background: var(--pc-surface-soft);
    color: var(--pc-text);
    border: 1px solid var(--pc-border);
}

.plc-modal-btn--secondary:hover {
    background: rgba(122, 19, 50, 0.04);
    border-color: rgba(122, 19, 50, 0.2);
}

/* ================================
   Accessibility
   ================================ */
.plc-widget :focus:not(:focus-visible) {
    outline: none;
}

.plc-widget :focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 2px;
}

.plc-widget .plc-input:focus,
.plc-widget .plc-input:focus-visible {
    outline: none;
    box-shadow: none;
}
