@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Corporate Premium Palette */
    --primary-color: #0f172a;
    /* Slate 900 */
    --primary-hover: #1e293b;
    /* Slate 800 */
    --accent-color: #3b82f6;
    /* Blue 500 */
    --bg-color: #f8fafc;
    /* Slate 50 */
    --sidebar-bg: #0f172a;
    --sidebar-text: #e2e8f0;
    --sidebar-hover: #1e293b;
    --chat-bg: #ffffff;
    --message-user-bg: #3b82f6;
    --message-user-text: #ffffff;
    --message-bot-bg: #f1f5f9;
    /* Slate 100 */
    --message-bot-text: #334155;
    /* Slate 700 */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

/* --- PREMIUM MAGIC CARD --- */
.magic-card-wrapper {
    position: relative;
    padding: 2px;
    /* For border width */
    border-radius: 12px;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    background-size: 200% 200%;
    animation: gradientMove 3s ease infinite;
    box-shadow: 0 4px 15px -3px rgba(99, 102, 241, 0.3);
    overflow: hidden;
    min-width: 280px;
    max-width: 100%;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.magic-card-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    /* Nearly matches wrapper */
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.magic-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    /* Slightly larger for image */
    height: 48px;
    background: transparent;
    /* Remove background box */
    border-radius: 0;
    color: #6366f1;
}

.galax-pulse-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    15% {
        transform: scale(1.15);
        opacity: 0.8;
    }

    /* Beat 1 */
    30% {
        transform: scale(1);
        opacity: 1;
    }

    45% {
        transform: scale(1.15);
        opacity: 0.8;
    }

    /* Beat 2 */
    60% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }

    /* Rest */
}

.magic-text-container {
    display: flex;
    flex-direction: column;
}

.magic-text-primary {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 14px;
    background: linear-gradient(90deg, #1e293b, #334155);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Gradient text */
    /* Fallback color if gradient fails */
    color: #1e293b;
}

/* Override transparent color with gradient only if supported */
@supports (background-clip: text) or (-webkit-background-clip: text) {
    .magic-text-primary {
        color: transparent;
    }
}

.magic-text-secondary {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.stars-loader {
    display: flex;
    gap: 4px;
}

.stars-loader i {
    color: #6366f1;
    /* Indigo to match theme */
    font-size: 12px;
    animation: starPulse 1.5s infinite ease-in-out;
}

.stars-loader i:nth-child(2) {
    animation-delay: 0.2s;
    color: #a855f7;
    /* Purple */
}

.stars-loader i:nth-child(3) {
    animation-delay: 0.4s;
    color: #ec4899;
    /* Pink */
}

@keyframes starPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.4);
        opacity: 1;
    }
}

body {
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    /* flex-direction: column; REMOVED to fix Chat Layout where Sidebar is left */
    color: #334155;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Jira Embedded Mode - Hide Sidebar */
body.jira-embedded .sidebar {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 64px;
    /* Compact width */
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    z-index: 10;
    transition: width 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center content */
    gap: 0;
}

.sidebar-header h2 {
    display: none;
    /* Hide title */
}

/* Show a small logo or icon instead of title if needed, 
   but for now we'll just keep it empty or rely on nav icons */
.sidebar-header::after {
    content: "AI";
    font-weight: 700;
    color: white;
    font-size: 1.2rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center icons */
    padding: 0.875rem 0;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0;
    /* Hide text */
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background-color: var(--sidebar-hover);
    color: white;
}

.sidebar-nav i {
    margin-right: 0;
    /* Remove margin */
    width: auto;
    text-align: center;
    font-size: 1.25rem;
    /* Ensure icon size */
}

.sidebar-footer {
    padding: 1.5rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: white;
    font-weight: 500;
}

.user-info span {
    display: none;
    /* Hide username */
}

.user-info i {
    font-size: 1.5rem;
    margin-right: 0;
    color: #94a3b8;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0;
    /* Hide text */
    transition: color 0.2s;
    width: 100%;
}

.logout-btn:hover {
    color: #ef4444;
}

.logout-btn i {
    margin-right: 0;
    font-size: 1.25rem;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
}

.chat-header {
    padding: 1.25rem 2rem;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.messages-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message.system {
    align-self: center;
    max-width: 100%;
    margin-bottom: 1rem;
}

.message .content {
    padding: 1rem 1.5rem;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.message.user .content {
    background-color: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 4px;
    background-image: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.message.assistant .content {
    background-color: white;
    color: var(--message-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message.system .content {
    background-color: transparent;
    color: #64748b;
    font-size: 0.875rem;
    text-align: center;
    box-shadow: none;
    border: 1px dashed var(--border-color);
}

/* Input Area */
.input-area {
    padding: 1.5rem 2rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
}

#chat-form {
    display: flex;
    gap: 1rem;
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

#chat-form button {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

#chat-form button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Professional Modern Table Styles */
.message table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1rem 0;
    font-size: 0.875rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    background: white;
}

.message th {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    /* Primary Dark Blue */
    color: #ffffff;
    font-weight: 600;
    text-align: left;
    padding: 14px 16px;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.message th:first-child {
    border-top-left-radius: 12px;
}

.message th:last-child {
    border-top-right-radius: 12px;
}

.message td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    vertical-align: middle;
    transition: background-color 0.15s ease;
}

/* Zebra striping */
.message tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.message tbody tr:last-child td {
    border-bottom: none;
}

.message tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.message tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Row hover effect */
.message tbody tr:hover td {
    background-color: #eef2ff;
}

/* Links in tables */
.message td a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    padding: 4px 10px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-radius: 6px;
    display: inline-block;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.message td a:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Status-like styling for common text */
.message td:first-child {
    font-weight: 600;
    color: #1e293b;
}

/* Typing Indicator (Loader) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    /* Slate 300 */
    transition: .4s;
    border-radius: 20px;
}

.toggle-switch label:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked+label {
    background-color: #10b981;
    /* Emerald 500 */
}

.toggle-switch input:checked+label:before {
    transform: translateX(20px);
}

/* --- MAGIC CARD LOADING INDICATOR --- */
@keyframes gradient-border {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes spin-ring {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.magic-card-wrapper {
    position: relative;
    padding: 2px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    background-size: 200% 200%;
    animation: gradient-border 3s ease infinite;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.3);
    margin-bottom: 5px;
    max-width: fit-content;
    z-index: 10;
}

.magic-card-inner {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(10px);
    min-width: 280px;
}

.magic-card-icon-box {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0fdf4;
    border-radius: 12px;
}

.magic-card-spinner {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    border: 2px solid transparent;
    border-top-color: #a855f7;
    border-right-color: #6366f1;
    animation: spin-ring 1.5s linear infinite;
}