/* GLOBAL RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Inter", Arial, sans-serif;
}

/* LOADING SCREEN */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.loading-logo {
    width: 150px;
    height: 150px;
    border-radius: 30px;
    background: #ffffff;
    padding: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: rotate 2s linear infinite;
    margin-bottom: 30px;
    object-fit: contain;
}

.loading-text {
    color: white;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.5px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* CHAT CONTAINER FULL SCREEN */
.chat-container {
    width: 98%;
    max-width: 1600px;
    height: 95vh;
    display: flex;
    gap: 16px;
    animation: fadeIn 0.5s ease-in;
}

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

/* LEFT PANEL: History */
.history-box {
    width: 22%;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow-y: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.history-box.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
}

.history-box:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    transform: translateY(-2px);
}

.history-box.collapsed:hover {
    transform: translateX(-100%);
}
.close-sidebar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
}

.close-sidebar:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
    transform: rotate(90deg);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    margin-top: 25px;
    position: relative;
}
.history-header h2 {
    font-size: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#newChatBtn {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
#newChatBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
#newChatBtn:active {
    transform: translateY(0);
}
#history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#history-list li {
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(135deg, #f7f9fc, #ffffff);
    border: 1px solid #e6eef8;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.delete-chat-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    color: #666;
}

.delete-chat-btn:hover {
    opacity: 1;
    background-color: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    transform: scale(1.1);
}

#history-list li::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s ease;
}
#history-list li:hover::before {
    left: 100%;
}
#history-list li:hover {
    background: linear-gradient(135deg, #eef6ff, #f0f4ff);
    transform: translateX(5px);
    border-color: #667eea;
}

/* TOGGLE BUTTONS */
.toggle-sidebar {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    display: none;
}

.toggle-sidebar:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.toggle-sidebar:active {
    transform: translateY(-50%) scale(0.95);
}

.left-toggle {
    left: 20px;
}

.right-toggle {
    right: 20px;
}

.toggle-sidebar.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: toggleAppear 0.3s ease-out;
}

@keyframes toggleAppear {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* CENTER PANEL: Chat */
.chat-box {
    width: 56%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-box.expanded-left {
    width: 78%;
}

.chat-box.expanded-right {
    width: 78%;
}

.chat-box.expanded-both {
    width: 100%;
}

.chat-box:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}
.chat-header {
    text-align: center;
    padding: 24px 24px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}
.chat-logo {
    width: clamp(64px, 7vw, 88px);
    height: clamp(64px, 7vw, 88px);
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    border-radius: 22px;
    background: #ffffff;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.7);
    object-fit: contain;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.chat-logo:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.5);
    filter: saturate(1.05);
}

.chat-header h1 {
    font-size: 32px;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.chat-header p {
    font-size: 16px;
    position: relative;
    z-index: 1;
    opacity: 0.95;
}
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f1f5f9;
}

.hidden {
    display: none !important;
}
.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.chat-logo-large {
    width: clamp(140px, 26vw, 210px);
    height: clamp(140px, 26vw, 210px);
    border-radius: 30px;
    background: #ffffff;
    padding: 10px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.9);
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    animation: emptyLogoFloat 4s ease-in-out infinite;
}

.empty-subtitle {
    margin-top: 0;
    font-size: 18px;
    font-weight: 500;
    color: #0f172a;
    text-align: center;
    max-width: 560px;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

@keyframes emptyLogoFloat {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.55);
    }
    50% {
        transform: translateY(-6px);
        box-shadow: 0 24px 55px rgba(15, 23, 42, 0.6);
    }
}
.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.5;
    animation: messageSlide 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.user-message {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.bot-message {
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}
.chat-input-area {
    display: flex;
    padding: 12px 16px;
    gap: 10px;
    border-top: 1px solid #e5e7eb;
    background: white;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}
#userInput {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
    border-radius: 14px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    outline: none;
}

#userInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#sendBtn {
    padding: 0 30px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#sendBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#sendBtn:active {
    transform: translateY(0);
}

/* RIGHT PANEL: Suggestions */
.suggestions-box {
    width: 22%;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow-y: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.suggestions-box.collapsed {
    transform: translateX(100%);
    opacity: 0;
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
}

.suggestions-box:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    transform: translateY(-2px);
}

.suggestions-box.collapsed:hover {
    transform: translateX(100%);
}
.suggestions-box h2 {
    font-size: 20px;
    margin-bottom: 15px;
    margin-top: 25px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#suggestion-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#suggestion-list li {
    font-size: 15px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border-radius: 12px;
    line-height: 1.5;
    background: linear-gradient(135deg, #ffffff, #f8f9fc);
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: space-between;
    gap: 8px; /* Add gap between text and arrow */
    min-height: 48px; /* Ensure minimum touch target size */
    height: auto; /* Allow height to grow */
}

#suggestion-list li::before {
    display: none;
}

#suggestion-list li:hover {
    transform: translateX(0);
    padding-left: 16px;
    border-left-color: #667eea;
    background: linear-gradient(135deg, #eef6ff, #f0f4ff);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

#suggestion-list li:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Add text wrapper to allow proper wrapping */
#suggestion-list li::after {
    content: '→';
    color: #667eea;
    font-weight: bold;
    font-size: 18px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    flex-shrink: 0; /* Prevent arrow from shrinking */
}

#suggestion-list li:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: all 0.3s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3, #6a3f91);
}

/* Mobile */
@media (max-width: 1100px) {
    body {
        overflow: auto;
    }

    .chat-container {
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 100vh;
        gap: 0;
        padding: 0;
    }

    /* Hide sidebars by default on mobile */
    .history-box,
    .suggestions-box {
        position: fixed;
        top: 0;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        min-width: auto;
        z-index: 1001;
        border-radius: 0;
        transform: translateX(-100%);
        opacity: 0;
    }

    .history-box {
        left: 0;
    }

    .suggestions-box {
        right: 0;
        left: auto;
        transform: translateX(100%);
    }

    /* Show sidebars when not collapsed */
    .history-box:not(.collapsed) {
        transform: translateX(0);
        opacity: 1;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .suggestions-box:not(.collapsed) {
        transform: translateX(0);
        opacity: 1;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* Always show toggle buttons on mobile */
    .toggle-sidebar {
        display: flex !important;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .toggle-sidebar.visible {
        display: flex !important;
    }

    .left-toggle {
        left: 15px;
        top: 15px;
        transform: none;
    }

    .right-toggle {
        right: 15px;
        top: 15px;
        transform: none;
    }

    .toggle-sidebar:hover {
        transform: scale(1.1);
    }

    /* Chat box takes full width on mobile */
    .chat-box {
        width: 100% !important;
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }

    .chat-box.expanded-left,
    .chat-box.expanded-right,
    .chat-box.expanded-both {
        width: 100% !important;
    }

    .chat-header {
        border-radius: 0;
        padding: 60px 20px 20px;
    }

    .chat-logo {
        width: 65px;
        height: 65px;
        margin-bottom: 10px;
    }

    .chat-header h1 {
        font-size: 26px;
    }

    .chat-header p {
        font-size: 14px;
    }

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

    .message {
        max-width: 85%;
        font-size: 15px;
        padding: 12px 14px;
    }

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

    #userInput {
        padding: 14px 16px;
        font-size: 16px;
    }

    #sendBtn {
        padding: 0 20px;
        font-size: 15px;
    }

    /* History header adjustments */
    .history-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .history-header h2 {
        text-align: center;
    }

    #newChatBtn {
        width: 100%;
        padding: 10px;
    }

    /* Optimized Suggestions for Mobile */
    .suggestions-box h2 {
        text-align: center;
        font-size: 18px;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 2px solid rgba(102, 126, 234, 0.2);
    }

    #suggestion-list {
        max-height: calc(100vh - 150px);
        overflow-y: auto;
        padding-right: 8px;
    }

    #suggestion-list li {
        font-size: 15px;
        padding: 14px 16px;
        margin-bottom: 12px;
        border-radius: 12px;
        line-height: 1.5;
        background: linear-gradient(135deg, #ffffff, #f8f9fc);
        border-left: 4px solid transparent;
        transition: all 0.3s ease;
        display: flex; /* Use flexbox for alignment */
        align-items: flex-start; /* Vertically center content */
        justify-content: space-between; /* Push text and arrow apart */
        gap: 8px; /* Add gap between text and arrow */
        min-height: 48px; /* Ensure minimum touch target size */
        height: auto; /* Allow height to grow */
    }

    #suggestion-list li::before {
        display: none;
    }

    #suggestion-list li:hover {
        transform: translateX(0);
        padding-left: 16px;
        border-left-color: #667eea;
        background: linear-gradient(135deg, #eef6ff, #f0f4ff);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    }

    #suggestion-list li:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    }

    /* Add text wrapper to allow proper wrapping */
    #suggestion-list li::after {
        content: '→';
        color: #667eea;
        font-weight: bold;
        font-size: 18px;
        opacity: 0;
        transform: translateX(-10px);
        transition: all 0.3s ease;
        flex-shrink: 0; /* Prevent arrow from shrinking */
    }

    #suggestion-list li:hover::after {
        opacity: 1;
        transform: translateX(0);
    }

    /* Overlay for sidebars */
    .history-box.collapsed::after,
    .suggestions-box.collapsed::after {
        content: none !important;
    }

    .close-sidebar {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    /* Ensure lists are scrollable */
    #history-list {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        padding-right: 8px;
    }

    #history-list li {
        font-size: 14px;
        padding: 12px 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    .chat-header {
        padding: 50px 15px 15px;
    }

    .chat-logo {
        width: 55px;
        height: 55px;
        margin-bottom: 8px;
    }

    .chat-header h1 {
        font-size: 22px;
    }

    .chat-header p {
        font-size: 13px;
    }

    .message {
        max-width: 90%;
        font-size: 14px;
        padding: 10px 12px;
    }

    .chat-input-area {
        flex-direction: column;
    }

    #userInput {
        width: 100%;
    }

    #sendBtn {
        width: 100%;
        padding: 14px;
    }

    .toggle-sidebar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .left-toggle {
        left: 10px;
        top: 10px;
    }

    .right-toggle {
        right: 10px;
        top: 10px;
    }

    .history-box,
    .suggestions-box {
        width: 90%;
        max-width: 100%;
    }

    /* Further optimize suggestions on smaller tablets */
    #suggestion-list li {
        font-size: 14px;
        padding: 12px 14px;
        line-height: 1.5;
    }

    .suggestions-box h2 {
        font-size: 17px;
    }
}

@media (max-width: 480px) {
    .chat-logo {
        width: 50px;
        height: 50px;
        margin-bottom: 6px;
    }

    .chat-header h1 {
        font-size: 20px;
    }

    .chat-header p {
        font-size: 12px;
    }

    .message {
        font-size: 13px;
        padding: 9px 11px;
    }

    #suggestion-list li {
        font-size: 13px;
        padding: 11px 13px;
        line-height: 1.6;
        margin-bottom: 10px;
    }

    #history-list li {
        font-size: 13px;
        padding: 10px 12px;
        line-height: 1.4;
    }

    .suggestions-box h2,
    .history-header h2 {
        font-size: 16px;
    }

    /* Adjust close button for small screens */
    .close-sidebar {
        width: 32px;
        height: 32px;
        font-size: 18px;
        top: 8px;
        right: 8px;
    }

    /* Make suggestion sidebar wider on very small screens */
    .suggestions-box {
        width: 95%;
    }
}