/**
 * Public Chat - CSS
 * Nordersun v6.2
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0071dc 0%, #004f9a 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================
   HEADER
   ============================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 15px 0;
}

.header-top {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    width: 40px;
    height: 40px;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    color: #0071dc;
}

.highlight-text {
    color: #ffc220;
}

.back-home-btn {
    background: linear-gradient(135deg, #0071dc 0%, #005bb5 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.back-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 220, 0.3);
}

/* ============================
   CHAT CONTAINER
   ============================ */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 700px;
    width: 100%;
    margin: 80px auto 0;
    padding: 20px;
}

/* ============================
   START FORM (View 1)
   ============================ */

.chat-start-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px 30px;
    margin-top: 40px;
}

.chat-start-header {
    text-align: center;
    margin-bottom: 30px;
}

.chat-start-header .chat-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #0071dc 0%, #005bb5 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 30px;
    color: white;
}

.chat-start-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.chat-start-header p {
    font-size: 15px;
    color: #666;
    line-height: 1.5;
}

.chat-form-group {
    margin-bottom: 18px;
}

.chat-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.chat-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: #333;
    transition: all 0.3s ease;
    background: white;
}

.chat-form-group input:focus {
    outline: none;
    border-color: #0071dc;
    box-shadow: 0 0 0 3px rgba(0, 113, 220, 0.1);
}

/* Honeypot field */
.chat-hp-field {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
}

.chat-start-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #0071dc 0%, #005bb5 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 113, 220, 0.4);
}

.chat-start-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================
   LIVE CHAT (View 2)
   ============================ */

.chat-live-card {
    display: none;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 120px);
    max-height: 700px;
}

.chat-live-card.active {
    display: flex;
}

/* Chat Header */
.chat-live-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0071dc 0%, #005bb5 100%);
    color: white;
    flex-shrink: 0;
}

.chat-live-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-live-header-left .agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-live-header-left .agent-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-live-header-left .agent-info .status-text {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-live-header-left .agent-info .status-dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.chat-end-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-end-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f7fb;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

/* Message Bubbles */
.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: bubbleIn 0.2s ease;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.visitor {
    background: linear-gradient(135deg, #0071dc, #005bb5);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.admin {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.chat-bubble .bubble-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.chat-bubble.visitor .bubble-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

.chat-bubble.admin .bubble-time {
    text-align: left;
    color: #999;
}

.chat-bubble.admin .bubble-sender {
    font-size: 12px;
    font-weight: 600;
    color: #0071dc;
    margin-bottom: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    background: white;
    padding: 12px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.typing-indicator.active {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Date separator */
.chat-date-separator {
    text-align: center;
    padding: 8px 0;
}

.chat-date-separator span {
    background: #e0e4ea;
    color: #666;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 12px;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid #e8e8e8;
    background: white;
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: #333;
    transition: border-color 0.2s;
    outline: none;
}

.chat-input-area input:focus {
    border-color: #0071dc;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0071dc, #005bb5);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 113, 220, 0.4);
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Session ended state */
.chat-ended-notice {
    display: none;
    text-align: center;
    padding: 16px;
    background: #f0f4f8;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.chat-ended-notice p {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.chat-new-btn {
    background: linear-gradient(135deg, #0071dc, #005bb5);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-new-btn:hover {
    transform: translateY(-1px);
}

/* ============================
   HIDDEN UTILITY
   ============================ */

.hidden {
    display: none !important;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
    .chat-container {
        margin-top: 70px;
        padding: 12px;
    }

    .chat-start-card {
        margin-top: 20px;
        padding: 30px 20px;
    }

    .chat-start-header h1 {
        font-size: 24px;
    }

    .chat-live-card {
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 16px;
    }

    .chat-bubble {
        max-width: 85%;
    }

    .back-home-btn span {
        display: none;
    }
}

@media (max-width: 480px) {
    .chat-container {
        margin-top: 65px;
        padding: 8px;
    }

    .chat-start-card {
        padding: 25px 15px;
        border-radius: 16px;
    }

    .chat-live-card {
        height: calc(100vh - 85px);
        border-radius: 12px;
    }

    .chat-live-header {
        padding: 12px 16px;
    }

    .chat-messages {
        padding: 14px;
    }

    .chat-bubble {
        max-width: 90%;
        font-size: 13px;
    }
}
