﻿body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: #0f0d1a; /* Dark Navy-Purple Base */
    color: #ffffff; /* Pure White Text */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 1. Header Navigation Bar */
.app-header {
    background: #171427;
    border-bottom: 1px solid #2e264f;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff
}

/* Dynamic API Status Indicator Pill */
.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #c4b5fd;
    background: #221c38;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #3c325c;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981; /* Green when connected */
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    transition: all 0.3s ease;
}

    .status-dot.offline {
        background: #ef4444; /* Red when disconnected */
        box-shadow: 0 0 8px #ef4444;
    }

/* Header Close Button */
.mchat-close-button {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #a78bfa;
    font-size: 18px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .mchat-close-button:hover {
        background: #ef4444;
        color: #ffffff;
    }

/* 2. Main Workspace Layout (Strict fit, no window scrolling) */
.workspace {
    width: 100%;
    height: calc(100% - 53px); /* Takes precise remaining height under header */
    padding: 16px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 16px;
}

.panel {
    background: #171427;
    border: 1px solid #2e264f;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2e264f;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #c4b5fd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Form Controls */
.field-group {
    margin-bottom: 12px;
}

.field-label {
    display: flex;
    justify-content: space-between;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

textarea, .search-input {
    width: 100%;
    background: #221c38;
    color: #ffffff;
    border: 1px solid #3c325c;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease-in-out;
}

textarea {
    height: 80px;
    resize: none; /* Prevents user resize from causing overflow scrollbars */
}

    textarea:focus, .search-input:focus, .dropdown-wrapper.active .search-input {
        border-color: #8b5cf6;
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    }

/* 3. Action Buttons */
.mbtn-secondary {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

    .mbtn-secondary:hover {
        box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
        transform: translateY(-1px);
    }

.mbtn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
    transition: all 0.2s ease;
}

    .mbtn-primary:hover {
        box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
        transform: translateY(-1px);
    }

/* 4. Dropdown & Tags Components */
.mdropdown-wrapper {
    position: relative;
    width: 100%;
}

.mdropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #221c38;
    border: 1px solid #3c325c;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 140px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.mdropdown-wrapper.active .mdropdown-menu {
    display: block;
}

.mdropdown-wrapper.active .search-input {
    border-radius: 8px 8px 0 0;
}

.dropdown-item {
    padding: 8px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}

    .dropdown-item:hover {
        background: #2e264f;
    }

    .dropdown-item input {
        accent-color: #f97316;
        margin-right: 10px;
        cursor: pointer;
    }

    .dropdown-item label {
        margin-bottom: 0;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        color: #ffffff;
    }

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 34px;
    max-height: 60px;
    overflow-y: auto;
    padding: 4px 6px;
    background: #221c38;
    border: 1px dashed #3c325c;
    border-radius: 8px;
    align-items: center;
}

.tag {
    background: rgba(249, 115, 22, 0.15);
    color: #ffedd5;
    border: 1px solid rgba(249, 115, 22, 0.5);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

    .tag .remove-tag {
        cursor: pointer;
        font-weight: bold;
        color: #f97316;
    }

        .tag .remove-tag:hover {
            color: #ffffff;
        }

/* 5. Floating Window & Trigger Controls */
.mchat-popup-container {
    position: fixed;
    right: 124px;
    bottom: 24px;
    z-index: 9999;
}

.mchat-toggle-button {
    border: 1px solid rgba(249, 115, 22, 0.5);
    border-radius: 50px;
    padding: 12px 24px;
    font-weight: 700;
    font-size: 14px;
    color: #ffffff;
    background: linear-gradient(135deg, #171427 0%, #221c38 100%);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 15px rgba(249, 115, 22, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .mchat-toggle-button:hover {
        background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
        border-color: transparent;
        box-shadow: 0 8px 25px rgba(249, 115, 22, 0.4);
        transform: translateY(-2px);
    }

.mchat-window {
    width: 780px;
    height: 480px;
    position: absolute;
    right: 0;
    bottom: 60px;
    border-radius: 16px;
    background: #0f0d1a;
    border: 1px solid #2e264f;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mchat-window-hidden {
    display: none;
}


@media (max-width: 480px) {
    .mchat-popup-container {
        right: 132px;
        bottom: 14px;
    }

    .mchat-window {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 72px;
        width: auto;
        height: min(520px, calc(100dvh - 100px));
        max-width: none;
        border-radius: 14px;
    }

    .mchat-toggle-button {
        padding: 11px 18px;
        font-size: 13px;
    }
}

