/* ==========================================================================
   ToyotaFixCare - Master Responsive Stylesheet
   Fully Responsive Across All Dimensions: Mobile, Tablet, Laptop, Desktop
   ========================================================================== */

/* Universal Box Sizing & Fluid Resets */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(to bottom, #141414, #0b1a2d);
    color: #FFF;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    flex-direction: row;
    position: relative;
}

/* ==========================================================================
   Sidebar Navigation & History Drawer
   ========================================================================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    height: 100vh;
    height: 100dvh;
    background-color: #000000;
    color: #7ac0e3;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(122, 192, 227, 0.25);
    border-right: 1px solid rgba(122, 192, 227, 0.2);
    position: relative;
    overflow-y: auto;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
}

.sidebar.hidden {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(122, 192, 227, 0.2);
    font-family: 'Segoe UI', Arial, sans-serif;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #7ac0e3;
}

.sidebar-header h2 {
    flex-grow: 1;
    font-size: 1.25rem;
    margin: 0;
    color: white;
    font-weight: 600;
}

.hamburger-menu {
    background: rgba(122, 192, 227, 0.15);
    border: 1px solid rgba(122, 192, 227, 0.3);
    border-radius: 8px;
    font-size: 20px;
    color: #7ac0e3;
    cursor: pointer;
    padding: 6px 10px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.hamburger-menu:hover {
    background-color: rgba(122, 192, 227, 0.35);
    color: #FFF;
}

.sidebar-close-btn {
    font-size: 16px;
    padding: 6px 10px;
    line-height: 1;
}

.header-burger {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

#headerHamburgerPlaceholder {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Sidebar Overlay for Mobile/Tablet */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Footer & Back Button */
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(122, 192, 227, 0.2);
}

.sidebar-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(122, 192, 227, 0.12);
    border: 1px solid rgba(122, 192, 227, 0.3);
    border-radius: 8px;
    color: #7ac0e3;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-back-btn:hover {
    background: #7ac0e3;
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(122, 192, 227, 0.3);
}

.sidebar .section {
    margin-bottom: 20px;
}

.sidebar .section h3 {
    font-size: 1.15em;
    margin-bottom: 10px;
    color: #7ac0e3;
}

.sidebar .history {
    max-height: 220px;
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.08);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar .history div,
.history-item {
    background-color: rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #eee;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    word-break: break-word;
}

.sidebar .history div:hover,
.history-item:hover {
    background-color: rgba(122, 192, 227, 0.2);
    color: #FFF;
}

.faq-question {
    font-size: 0.95rem;
    font-weight: bold;
    color: #7ac0e3;
    margin-top: 10px;
    margin-bottom: 4px;
    word-break: break-word;
}

.faq-answer {
    font-size: 0.88rem;
    margin-bottom: 12px;
    line-height: 1.45;
    color: #ddd;
    word-break: break-word;
}

/* ==========================================================================
   Chatbot Main Container
   ========================================================================== */
.chatbot-container {
    flex: 1 1 auto;
    min-width: 0; /* Prevents overflow expanding parent */
    width: calc(100% - 280px);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: transparent;
    position: relative;
    transition: width 0.3s ease;
    overflow: hidden;
}

.chatbot-container.fullscreen,
.sidebar.hidden ~ .chatbot-container {
    width: 100%;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(to right, #0b1a2d, #141414);
    border-bottom: 2px solid #7ac0e3;
    color: #7ac0e3;
    padding: 14px 20px;
    min-height: 65px;
    font-size: clamp(1.2rem, 3.5vw, 1.8rem);
    font-family: 'Impact', 'Segoe UI', Tahoma, sans-serif;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    width: 100%;
    position: relative;
}

.chat-header .logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #7ac0e3;
    display: block;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.chat-header .logo:hover {
    transform: scale(1.08);
}

.toyota {
    color: #c0990c;
}

.fix-care {
    color: #ffffff;
}

/* Chat Messages */
.chat-messages {
    flex: 1 1 auto;
    padding: clamp(14px, 3vw, 24px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    align-items: flex-start;
    max-width: 82%;
    position: relative;
}

.message img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin: 0 8px;
    flex-shrink: 0;
    object-fit: cover;
}

.message.user {
    flex-direction: row-reverse;
    text-align: left;
    align-self: flex-end;
    margin-left: auto;
}

.message.user .content {
    background: linear-gradient(135deg, #7ac0e3, #3a8fb7);
    color: #000;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px rgba(122, 192, 227, 0.25);
    padding: 12px 16px;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: clamp(0.92rem, 1.8vw, 1.05rem);
    line-height: 1.5;
}

.message.bot .content {
    background: linear-gradient(135deg, #1b2a47, #223246);
    color: #FFF;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(122, 192, 227, 0.4);
    padding: 12px 18px 36px 18px; /* Space for action icons */
    margin-left: 6px;
    max-width: 100%;
    min-width: 140px; /* Ensures room for icons even if message is brief */
    position: relative;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: clamp(0.92rem, 1.8vw, 1.05rem);
    line-height: 1.55;
}

.message-text {
    width: 100%;
    white-space: pre-wrap;
}

/* Action Icons Container (Speaker & Copy) di Ujung Kanan Bawah Balon Chat */
.icon-container {
    position: absolute;
    bottom: 6px;
    right: 8px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    background: rgba(11, 26, 45, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid rgba(122, 192, 227, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    user-select: none;
    z-index: 2;
}

.copy-icon,
.speaker-icon,
.tts-icon {
    font-size: 14px;
    cursor: pointer;
    color: #7ac0e3;
    padding: 3px 5px;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.copy-icon:hover,
.speaker-icon:hover,
.tts-icon:hover {
    color: #FFF;
    background: rgba(122, 192, 227, 0.25);
    transform: scale(1.15);
}

.copy-icon.success {
    color: #10b981;
    font-weight: bold;
    transform: scale(1.15);
}

.tts-icon.playing,
.speaker-icon.playing {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.25);
    animation: speakerPulse 1s infinite alternate;
}

@keyframes speakerPulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px #38bdf8); }
    100% { transform: scale(1.22); filter: drop-shadow(0 0 6px #38bdf8); }
}

/* Typing Indicator Animation */
.message.typing-indicator,
.typing-indicator {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.dots-container {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #1b2a47;
    padding: 10px 16px;
    border-radius: 18px;
    border: 1px solid rgba(122, 192, 227, 0.3);
}

.dots-container .dot,
.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: #7ac0e3;
    border-radius: 50%;
    animation: blink 1.4s infinite;
}

.dots-container .dot:nth-child(2),
.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dots-container .dot:nth-child(3),
.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ==========================================================================
   Chat Input Bar
   ========================================================================== */
.chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: clamp(10px, 2vw, 16px);
    background-color: #0b1a2d;
    border-top: 1px solid rgba(122, 192, 227, 0.4);
    width: 100%;
    flex-shrink: 0;
}

.chat-input input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 18px;
    border: 1px solid rgba(122, 192, 227, 0.5);
    border-radius: 25px;
    font-size: clamp(0.9rem, 2vw, 1rem);
    outline: none;
    background-color: #141414;
    color: white;
    transition: all 0.3s ease;
}

.chat-input input:focus {
    background-color: #1a2536;
    border-color: #7ac0e3;
    box-shadow: 0 0 10px rgba(122, 192, 227, 0.4);
}

.chat-input button,
.chat-input .voice-recording,
.chat-input .clear-input {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.chat-input button {
    background: linear-gradient(135deg, #1393d3, #0b6fa5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-input button:hover {
    background: #0ea5e9;
    transform: scale(1.06);
}

.chat-input .voice-recording {
    background-color: #075e54;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-input .voice-recording:hover {
    background-color: #0d8a7c;
    transform: scale(1.06);
}

.chat-input .voice-recording.recording {
    animation: pulseMic 1s infinite alternate;
    background-color: #dc2626;
}

@keyframes pulseMic {
    0% { transform: scale(1); }
    100% { transform: scale(1.2); }
}

.chat-input .clear-input {
    background-color: #c10909;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-input .clear-input:hover {
    background-color: #e51717;
    transform: scale(1.06);
}

/* ==========================================================================
   Modals & Popups (Full Responsive)
   ========================================================================== */
.confirmation-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #1b2a47;
    color: #FFF;
    padding: 24px;
    border-radius: 14px;
    border: 1px solid #7ac0e3;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.7);
    text-align: center;
    z-index: 2100;
    max-width: calc(100vw - 32px);
    width: 360px;
}

.popup-button {
    padding: 10px 22px;
    margin: 8px 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.yes-button {
    background-color: #10b981;
    color: white;
}

.yes-button:hover {
    background-color: #059669;
}

.no-button {
    background-color: #ef4444;
    color: white;
}

.no-button:hover {
    background-color: #dc2626;
}

/* Recording Popup */
.recording-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 26, 45, 0.95);
    border: 1px solid #7ac0e3;
    color: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 2100;
    text-align: center;
    max-width: calc(100vw - 32px);
    width: 300px;
}

.recording-popup.hidden {
    display: none;
}

.microphone-icon {
    font-size: 44px;
    margin-bottom: 10px;
    animation: pulseMic 1s infinite alternate;
}

.sound-wave {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 15px;
    height: 35px;
}

.wave {
    width: 6px;
    height: 20px;
    background: #7ac0e3;
    border-radius: 3px;
    animation: waveAnimation 1s infinite ease-in-out;
}

.wave:nth-child(2) {
    animation-delay: 0.2s;
}

.wave:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes waveAnimation {
    0%, 100% { height: 10px; }
    50% { height: 32px; }
}

/* Menu Dropdown Popup */
.popup-menu {
    position: absolute;
    background-color: #0b0f14;
    border: 1px solid #7ac0e3;
    padding: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    z-index: 2200;
    max-width: calc(100vw - 30px);
    width: 210px;
}

.popup-option {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    display: block;
    margin: 6px 0;
    background-color: #1a2536;
    color: #7ac0e3;
    border-radius: 6px;
    transition: all 0.2s ease;
    word-break: break-word;
}

.popup-option:hover {
    background-color: #7ac0e3;
    color: #000;
}

/* ==========================================================================
   MEDIA QUERIES UNTUK SEMUA DIMENSI LAYAR
   ========================================================================== */

/* Layar Tablet dan Di Bawahnya (<= 850px) */
@media (max-width: 850px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: min(300px, 85vw);
        min-width: unset;
        max-width: 85vw;
        z-index: 2000;
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.8);
        transform: translateX(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.hidden {
        display: flex !important;
        transform: translateX(-105%);
        pointer-events: none;
    }

    .chatbot-container {
        width: 100% !important;
        flex: 1 1 100%;
    }

    .message {
        max-width: 90%;
    }
}

/* Layar Ponsel & Smartphone (<= 480px) */
@media (max-width: 480px) {
    .chat-header {
        padding: 10px 12px;
        min-height: 56px;
        font-size: 1.15rem;
        gap: 8px;
    }

    .chat-header .logo {
        width: 35px;
        height: 35px;
    }

    .chat-messages {
        padding: 10px 8px;
        gap: 10px;
    }

    .message {
        max-width: 95%;
    }

    .message img {
        width: 32px;
        height: 32px;
        margin: 0 4px;
    }

    .message.user .content,
    .message.bot .content {
        padding: 10px 12px;
        font-size: 0.92rem;
    }

    .message.bot .content {
        padding-bottom: 34px;
    }

    .chat-input {
        padding: 8px 10px;
        gap: 5px;
    }

    .chat-input input {
        padding: 10px 14px;
        font-size: 0.88rem;
    }

    .chat-input button,
    .chat-input .voice-recording,
    .chat-input .clear-input {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 15px;
    }
}

/* Layar Ponsel Sangat Kecil (<= 360px) */
@media (max-width: 360px) {
    .chat-header {
        font-size: 1.05rem;
    }

    .chat-input button,
    .chat-input .voice-recording,
    .chat-input .clear-input {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 13px;
    }

    .chat-input {
        gap: 4px;
        padding: 6px 8px;
    }
}
