/* Dyronics Chat - Widget Styles */
:root {
    --drc-primary: #2271b1;
    --drc-hover: #1a5a8a;
    --drc-white: #ffffff;
    --drc-light-gray: #f5f5f5;
    --drc-border: #ddd;
    --drc-shadow: rgba(0, 0, 0, 0.15);
    --drc-text: #333;
    --drc-text-light: #666;
}

/* iOS Safari specific fixes */
.drc-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.drc-widget * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Position variations */
.drc-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.drc-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.drc-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--drc-primary-color, var(--drc-primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--drc-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.drc-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.drc-chat-button svg {
    width: 30px;
    height: 30px;
}

.drc-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.drc-status-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulse 2s ease-in-out infinite;
}

.drc-status-badge.online {
    background-color: #4ade80;
}

.drc-status-badge.offline {
    background-color: #ef4444;
}

/* Chat Window */
.drc-chat-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drc-position-bottom-left .drc-chat-window {
    left: 0;
}

.drc-position-bottom-right .drc-chat-window {
    right: 0;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.drc-chat-header {
    background: var(--drc-primary-color, var(--drc-primary));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drc-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.drc-agent-name {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
    font-weight: 400;
}

.drc-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.drc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

.drc-status-dot.online {
    background-color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.drc-status-dot.offline {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.drc-close-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.drc-close-button:hover {
    opacity: 1;
}

.drc-close-button svg {
    width: 24px;
    height: 24px;
}

/* Start Form */
.drc-start-form {
    padding: 30px 20px;
    flex: 1;
    overflow-y: auto;
}

.drc-welcome-message {
    background: var(--drc-light-gray);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.drc-start-form input,
.drc-start-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--drc-border);
    border-radius: 6px;
    font-size: 16px;
    margin-bottom: 12px;
    font-family: inherit;
}

.drc-start-form input:focus,
.drc-start-form textarea:focus {
    outline: none;
    border-color: var(--drc-primary-color, var(--drc-primary));
}

.drc-button {
    width: 100%;
    padding: 14px;
    background: var(--drc-primary-color, var(--drc-primary));
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.drc-button:hover {
    background: var(--drc-hover);
}

/* Messages Container */
.drc-messages-container {
    flex: 1;
    overflow-y: auto;
    background: var(--drc-light-gray);
}

.drc-messages {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drc-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.drc-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.drc-message.visitor {
    justify-content: flex-end;
}

.drc-message.visitor .drc-message-bubble {
    background: var(--drc-primary-color, var(--drc-primary));
    color: white;
    border-bottom-right-radius: 4px;
}

.drc-message.agent .drc-message-bubble,
.drc-message.system .drc-message-bubble {
    background: white;
    color: var(--drc-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.drc-message-time {
    font-size: 11px;
    color: var(--drc-text-light);
    margin-top: 4px;
}

/* Typing Indicator */
.drc-typing-indicator {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--drc-light-gray);
    font-size: 13px;
    color: var(--drc-text-light);
}

.drc-typing-indicator span:not(.drc-typing-text) {
    width: 8px;
    height: 8px;
    background: var(--drc-text-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.drc-typing-indicator span:nth-child(2) {
    animation-delay: -0.32s;
}

.drc-typing-indicator span:nth-child(3) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.drc-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid var(--drc-border);
}

.drc-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

#drc-message-input,
.drc-message-input {
    flex: 1;
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--drc-border);
    border-radius: 20px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 40px;
}

#drc-message-input:focus,
.drc-message-input:focus {
    outline: none;
    border-color: var(--drc-primary-color, var(--drc-primary));
}

.drc-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--drc-primary-color, var(--drc-primary));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.drc-send-button:hover {
    background: var(--drc-hover);
    transform: scale(1.05);
}

.drc-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.drc-send-button svg {
    width: 20px;
    height: 20px;
}

/* File Upload Button */
.drc-file-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--drc-border);
    color: var(--drc-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.drc-file-button:hover {
    background: var(--drc-light-gray);
    color: var(--drc-primary-color, var(--drc-primary));
    border-color: var(--drc-primary-color, var(--drc-primary));
    transform: scale(1.05);
}

.drc-file-button svg {
    width: 20px;
    height: 20px;
}

/* Attachment Display */
.drc-attachment {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.drc-message.visitor .drc-attachment {
    background: rgba(255, 255, 255, 0.2);
}

.drc-message.agent .drc-attachment,
.drc-message.system .drc-attachment {
    background: var(--drc-light-gray);
}

.drc-attachment a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.drc-attachment a:hover {
    text-decoration: underline;
}

.drc-message.visitor .drc-attachment a {
    color: white;
}

.drc-message.agent .drc-attachment a,
.drc-message.system .drc-attachment a {
    color: var(--drc-primary-color, var(--drc-primary));
}


/* Powered by */
.drc-powered-by {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    color: var(--drc-text-light);
    background: var(--drc-light-gray);
    border-top: 1px solid var(--drc-border);
}

/* Responsive Design */

/* Tablet (portrait) */
@media (max-width: 768px) and (min-width: 481px) {
    .drc-chat-window {
        width: 420px;
        max-width: calc(100vw - 40px);
        height: 580px;
        max-height: calc(100vh - 100px);
    }

    .drc-chat-button {
        width: 58px;
        height: 58px;
    }

    .drc-chat-button svg {
        width: 29px;
        height: 29px;
    }

    .drc-message-bubble {
        max-width: 75%;
    }
}

/* iPad/Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .drc-chat-window {
        width: 440px;
        height: 620px;
        max-height: calc(100vh - 100px);
    }

    .drc-message-bubble {
        max-width: 70%;
    }
}

/* iPad Pro landscape */
@media (min-width: 1025px) and (max-width: 1366px) {
    .drc-chat-window {
        width: 450px;
        height: 640px;
    }
}

/* Mobile (portrait) */
@media (max-width: 480px) {
    .drc-position-bottom-right {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }

    .drc-position-bottom-left {
        bottom: max(20px, env(safe-area-inset-bottom));
        left: max(20px, env(safe-area-inset-left));
    }

    .drc-chat-button {
        width: 56px;
        height: 56px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }

    .drc-chat-button:active {
        transform: scale(0.95);
    }

    .drc-chat-button svg {
        width: 28px;
        height: 28px;
    }

    .drc-chat-window {
        position: fixed;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport height for mobile browsers */
        max-width: 100%;
        max-height: 100%;
        top: 0;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        animation: slideUpFull 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-overflow-scrolling: touch;
    }

    .drc-chat-header {
        padding: max(16px, env(safe-area-inset-top)) 16px 16px;
        min-height: 64px;
        height: auto;
    }

    .drc-chat-header h3 {
        font-size: 17px;
        font-weight: 600;
    }

    .drc-status {
        font-size: 13px;
    }

    .drc-close-button {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        transition: background 0.2s;
    }

    .drc-close-button:active {
        background: rgba(255, 255, 255, 0.2);
    }

    .drc-start-form {
        padding: 20px 16px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .drc-welcome-message {
        font-size: 16px;
        padding: 16px;
        line-height: 1.5;
        border-radius: 12px;
    }

    .drc-start-form input,
    .drc-start-form textarea {
        padding: 14px 16px;
        font-size: 16px;
        /* Prevents iOS zoom */
        border-radius: 8px;
        border: 2px solid var(--drc-border);
        -webkit-appearance: none;
        appearance: none;
        background-color: white;
        -webkit-tap-highlight-color: transparent;
    }

    .drc-start-form input:focus,
    .drc-start-form textarea:focus {
        border-color: var(--drc-primary-color, var(--drc-primary));
        box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
        outline: none;
    }

    .drc-button {
        padding: 16px;
        font-size: 17px;
        font-weight: 600;
        border-radius: 8px;
        min-height: 48px;
    }

    .drc-button:active {
        transform: scale(0.98);
    }

    .drc-messages-container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .drc-messages {
        padding: 16px;
        gap: 14px;
    }

    .drc-message-bubble {
        padding: 12px 16px;
        font-size: 16px;
        line-height: 1.5;
        max-width: 80%;
        border-radius: 20px;
    }

    .drc-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .drc-message-input {
        padding: 14px 16px;
        font-size: 16px;
        /* Prevents iOS zoom */
        border-radius: 24px;
        border: 2px solid var(--drc-border);
        min-height: 48px;
        -webkit-appearance: none;
        appearance: none;
        background-color: white;
        -webkit-tap-highlight-color: transparent;
    }

    .drc-message-input:focus {
        border-color: var(--drc-primary-color, var(--drc-primary));
        box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
        outline: none;
    }

    .drc-send-button {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .drc-send-button:active {
        transform: scale(0.95);
    }

    .drc-send-button svg {
        width: 20px;
        height: 20px;
    }

    .drc-powered-by {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    /* iOS Safari keyboard fix */
    @supports (-webkit-touch-callout: none) {
        .drc-input-area {
            position: relative;
            padding-bottom: max(12px, calc(env(safe-area-inset-bottom) + 12px));
        }

        /* Fix for iOS Safari address bar issue */
        .drc-messages-container {
            max-height: calc(100vh - 200px);
            max-height: calc(100dvh - 200px);
        }
    }
}

/* Small mobile devices */
@media (max-width: 360px) {
    .drc-chat-button {
        width: 52px;
        height: 52px;
    }

    .drc-chat-button svg {
        width: 26px;
        height: 26px;
    }

    .drc-message-bubble {
        max-width: 75%;
        font-size: 14px;
    }
}

/* Landscape mobile (phones only) */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
    .drc-chat-window {
        height: 100vh;
        max-height: 100vh;
    }

    .drc-chat-header {
        padding: 10px 15px;
        min-height: 50px;
    }

    .drc-chat-header h3 {
        font-size: 16px;
    }

    .drc-messages {
        padding: 12px;
    }

    .drc-input-area {
        padding: 8px 12px;
    }

    .drc-message-input {
        min-height: 36px;
        padding: 8px 12px;
    }
}

/* Desktop large screens */
@media (min-width: 1200px) {
    .drc-chat-window {
        width: 420px;
        height: 650px;
    }
}

@keyframes slideUpFull {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading state */
.drc-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.drc-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--drc-border);
    border-top-color: var(--drc-primary-color, var(--drc-primary));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* System Message Styles */
.drc-system-message {
    padding: 15px;
    margin: 15px 0;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    text-align: center;
}

.drc-system-message p {
    margin: 0;
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
}