/* ===== GOPOS Chat Page - ChatGPT/Gemini Style ===== */

:root {
    /* Dark Theme - Improved Colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #212121;
    --bg-tertiary: #2d2d2d;
    --bg-sidebar: #1e1e1e;
    --bg-hover: #333333;
    --bg-message-user: #2d2d2d;
    --bg-message-bot: transparent;
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #3a3a3a;
    --accent-primary: #3b82f6;
    --accent-primary-rgb: 59, 130, 246;
    --accent-secondary: #60a5fa;
    --accent-gradient: linear-gradient(135deg, #1e3a5f 0%, #3b82f6 100%);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #eaeaea;
    --bg-sidebar: #f9fafb;
    --bg-hover: #ececec;
    --bg-message-user: #f7f7f8;
    --bg-message-bot: transparent;
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #9b9b9b;
    --border-color: #e5e5e5;
    --accent-primary-rgb: 59, 130, 246;
    --accent-secondary: #2563eb;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    animation: slideInLeft 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.new-chat-btn {
    margin: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
}

.history-section {
    margin-bottom: 1rem;
}

.history-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item .icon {
    font-size: 1rem;
}

.history-item .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.875rem;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport for mobile browsers */
    overflow: hidden;
    animation: fadeIn 0.8s ease-out;
}

/* Chat Header (Mobile) */
.chat-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-header h1 {
    font-size: 1rem;
    font-weight: 600;
}

.menu-btn,
.theme-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* ===== Welcome Screen ===== */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    min-height: 0;
}

.welcome-content {
    text-align: center;
    max-width: 700px;
    padding-bottom: 1rem;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
}

.welcome-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Suggestion Cards */
.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.suggestion-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.suggestion-card:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.card-icon {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Chat Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: none;
}

.chat-messages.active {
    display: block;
}

.message {
    padding: 1.5rem 2rem;
    display: flex;
    gap: 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.message-user {
    background: var(--bg-message-user);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--accent-primary);
    color: white;
}

.message-bot .message-avatar {
    background: var(--accent-gradient);
}

.message-content {
    flex: 1;
    line-height: 1.6;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content ul,
.message-content ol {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

/* Message Animations - Gemini Style */
.message {
    animation: messageSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

/* Typing effect for bot messages - Gemini style cursor */
.message-bot .message-content.typing {
    position: relative;
}

.message-bot .message-content.typing::after {
    content: '▋';
    display: inline-block;
    animation: cursorPulse 1s ease-in-out infinite;
    margin-left: 1px;
    color: var(--accent-primary);
    font-weight: 400;
}

@keyframes cursorPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Code styling for chat messages */
.message-content code {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85em;
    color: var(--accent-secondary);
}

.message-content pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

/* Table styling for chat messages */
.table-container {
    overflow-x: auto;
    margin: 0.75rem 0;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 280px;
}

.chat-table th,
.chat-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.chat-table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-table tbody tr:last-child td {
    border-bottom: none;
}

.chat-table tbody tr:hover {
    background: var(--bg-hover);
}

.chat-table td {
    color: var(--text-secondary);
}

/* Make first column standout */
.chat-table td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* Mobile responsiveness for tables */
@media (max-width: 480px) {
    .table-container {
        margin: 0.5rem 0;
        border-radius: 8px;
    }

    .chat-table th,
    .chat-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .chat-table th {
        font-size: 0.75rem;
    }
}

/* Bullet and number styling */
.message-content .bullet {
    color: var(--accent-primary);
    font-weight: 600;
}

.message-content .number {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Follow-up Suggestions - Gemini Style */
.follow-up-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 0;
    margin: 0;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.follow-up-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.follow-up-chip:hover {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4);
}

.follow-up-chip:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .follow-up-suggestions {
        padding: 0.75rem 0;
        gap: 0.5rem;
    }

    .follow-up-chip {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 0;
}

.typing-indicator span:not(.typing-text) {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s 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(-4px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    font-style: normal;
    white-space: nowrap;
}

/* ===== Chat Input ===== */
.chat-input-container {
    padding: 1rem 2rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    gap: 0.75rem;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    padding: 0.25rem 0;
}

#chatInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    background: #2563eb;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.mobile-overlay.active {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .chat-header {
        display: flex;
    }

    .main-content {
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport height for mobile */
    }

    .welcome-screen {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 1.5rem;
    }

    .welcome-content {
        width: 100%;
    }

    .welcome-content h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    .welcome-content p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .welcome-icon {
        width: 60px;
        height: 60px;
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .suggestion-card {
        padding: 0.75rem;
    }

    .card-icon {
        font-size: 1rem;
        margin-bottom: 0.125rem;
    }

    .card-title {
        font-size: 0.8rem;
    }

    .card-desc {
        font-size: 0.7rem;
    }

    .message {
        padding: 1rem;
    }

    .chat-input-container {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
    }

    .input-hint {
        font-size: 0.65rem;
        margin-top: 0.25rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }

    .welcome-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

@media (max-width: 480px) {
    .suggestion-cards {
        grid-template-columns: 1fr;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

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

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

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

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.welcome-content {
    animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.suggestion-card {
    animation: popIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.suggestion-card:nth-child(1) {
    animation-delay: 0.1s;
}

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

.suggestion-card:nth-child(3) {
    animation-delay: 0.3s;
}

.suggestion-card:nth-child(4) {
    animation-delay: 0.4s;
}

.chat-message {
    animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}