html {
    height: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* NAVIGATION */
nav {
    background: #e74c3c;
    padding: 1rem 2rem;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: white;
    text-decoration: none;
}

.nav-logo {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
}

.nav-logo img {
    width: 30px;
    height: 30px;
}

.nav-brand-text {
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.nav-menu a:hover {
    opacity: 0.8;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem;
    user-select: none;
    color: white;
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: white;
    min-width: 250px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    max-height: 0;
    overflow: hidden;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    max-height: 500px;
}

.dropdown-menu li {
    list-style: none;
}

.dropdown-menu a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: #666;
    text-decoration: none;
    transition: background 0.3s, color 0.3s;
    border-radius: 5px;
    margin: 0 0.5rem;
}

.dropdown-menu a:hover {
    background: #f8f8f8;
    color: #e74c3c;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
}

/* TOGGLE SIDEBAR — desktop hidden */
.toggle-sidebar {
    display: none !important;
}

/*  MAIN CONTAINER */
.main-container {
    display: flex;
    height: 100vh;
    padding-top: 70px;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: white;
    border-right: 1px solid #e0e0e0;
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
    height: 100%;
}

.sidebar-header {
    margin-bottom: 1rem;
}

.sidebar-header h3 {
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 600;
}

.new-chat-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.75rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 1.2rem;
}

.new-chat-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item {
    padding: 0.7rem 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-item:hover {
    background: #e8ecf1;
    border-left-color: #e74c3c;
}

.chat-item.active {
    background: #fef5f4;
    border-left-color: #e74c3c;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-title {
    font-size: 0.88rem;
    color: #2c3e50;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.72rem;
    color: #95a5a6;
    margin-top: 2px;
}

.chat-menu-btn {
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-item:hover .chat-menu-btn {
    opacity: 1;
}

.chat-menu-btn:hover {
    background: #e0e0e0;
    color: #2c3e50;
}

.chat-menu {
    position: absolute;
    right: 0.5rem;
    top: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem;
    z-index: 100;
    display: none;
    min-width: 120px;
    margin-top: 4px;
}

.chat-menu.open {
    display: block;
}

.chat-menu button {
    width: 100%;
    background: none;
    border: none;
    padding: 0.6rem 1rem;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #e74c3c;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-menu button:hover {
    background: #fef5f4;
}

/* CHAT CONTAINER */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    overflow: hidden;
    min-width: 0;
}

.chat-header {
    padding: 1.2rem 2rem;
    border-bottom: 1px solid #e8ecf1;
    background: white;
    flex-shrink: 0;
}

.chat-header h1 {
    color: #e74c3c;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

/*  MESSAGES  */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1rem;
    min-height: 0;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
    flex: 1;
    padding: 2rem;
}

.empty-state p {
    font-size: 1rem;
    color: #95a5a6;
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.empty-state p strong {
    color: #555;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.empty-state p img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/*  MESSAGE BUBBLES */
.message-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 75%;
}

.message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

.message {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.93rem;
    line-height: 1.6;
    color: #2c3e50;
    max-width: 100%;
    word-wrap: break-word;
}

.user-message {
    background: #e74c3c;
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.message-content {
    line-height: 1.65;
}

/* MESSAGE CONTENT FORMATTING */
.message-content {
    line-height: 1.7;
    font-size: 0.93rem;
}

.msg-section-title {
    font-weight: 600;
    color: #2c3e50;
    margin: 12px 0 6px;
    font-size: 0.95rem;
}

.msg-section-title:first-child {
    margin-top: 0;
}

.msg-list-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 5px 0;
    padding-left: 4px;
}

.msg-num {
    color: #e74c3c;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 20px;
}

.msg-bullet {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 4px 0;
    padding-left: 4px;
}

.msg-dot {
    color: #e74c3c;
    font-weight: 700;
    flex-shrink: 0;
}

.msg-spacer {
    height: 8px;
}

/* DISCLAIMER */
.disclaimer {
    background: #fef5f4;
    border: 1px solid rgba(231, 76, 60, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #c0392b;
    text-align: center;
    align-self: center;
    max-width: 500px;
    width: 100%;
    flex-shrink: 0;
}

/* TYPING INDICATOR */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-items: center;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* INPUT AREA */
.input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e8ecf1;
    background: white;
    flex-shrink: 0;
}

.guest-limit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: .82rem;
    margin-bottom: 8px;
    border: 1px solid #eee;
    background: #f8f8f8;
    transition: all .3s;
}

.guest-login-link {
    color: #e74c3c;
    font-weight: 600;
    text-decoration: none;
    font-size: .8rem;
    white-space: nowrap;
}

.guest-login-link:hover {
    text-decoration: underline;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: #f8f9fa;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: #e74c3c;
    background: white;
    box-shadow: 0 2px 12px rgba(231, 76, 60, 0.1);
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: #2c3e50;
    outline: none;
    font-family: inherit;
}

.input-wrapper input::placeholder {
    color: #aaa;
}

.send-btn {
    background: #e74c3c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* SCROLLBAR */
.messages-container::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.messages-container::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* ANIMATION */
.animate-in {
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RESPONSIVE */

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: #e74c3c;
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        display: none;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        z-index: 999;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu>li>a {
        padding: 0.9rem 1.5rem;
    }

    .dropdown-toggle {
        padding: 0.9rem 1.5rem;
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.12);
        margin: 0;
        display: none;
        max-height: none;
        overflow: visible;
    }

    .dropdown.active .dropdown-menu {
        display: block;
    }

    .dropdown-menu a {
        color: white;
        padding: 0.7rem 2.2rem;
        margin: 0;
    }

    .dropdown-menu a:hover {
        background: rgba(255, 255, 255, 0.12);
    }

    /* Sidebar */
    .sidebar {
        position: fixed;
        left: 0;
        top: 70px;
        height: calc(100vh - 70px);
        transform: translateX(-100%);
        z-index: 900;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
        background: white;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Chat layout */
    .chat-header h1 {
        font-size: 1.15rem;
    }

    .messages-container {
        padding: 1rem;
        gap: 0.75rem;
    }

    .message-wrapper {
        max-width: 90%;
    }

    .message {
        font-size: 0.9rem;
        padding: 9px 12px;
    }

    .input-container {
        padding: 0.75rem 1rem;
    }

    .input-wrapper {
        padding: 0.55rem 0.85rem;
        border-radius: 10px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
        border-radius: 9px;
    }

    /* Sidebar toggle */
    .toggle-sidebar {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 78px;
        left: 12px;
        z-index: 950;
        background: #e74c3c;
        color: white;
        border: none;
        border-radius: 8px;
        width: 36px;
        height: 36px;
        font-size: 1rem;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .disclaimer {
        font-size: 0.78rem;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 1rem;
    }

    .message-wrapper {
        max-width: 94%;
    }

    .message {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .messages-container {
        padding: 0.75rem;
    }

    .input-container {
        padding: 0.6rem 0.75rem;
    }

    .input-wrapper input {
        font-size: 0.9rem;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }
}