/* =========================================
   1. RESET AND BASE STYLES
   ========================================= */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    overflow: hidden;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* =========================================
   2. MAIN LAYOUT
   ========================================= */
.container {
    display: flex;
    width: 100%;
    height: 100vh;
    background-color: #16213e;
    overflow: hidden;
}

.main-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
}

/* =========================================
   3. SIDEBAR
   ========================================= */
.sidebar {
    width: 180px;
    background-color: #0f3460;
    color: white;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 10;
}

.sidebar .logo {
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
    padding: 0 15px;
    width: 100%;
    height: 50px;
}

.sidebar .logo img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar .main-nav {
    width: 100%;
    flex-grow: 1;
}

.sidebar .main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar .main-nav a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #a0a7b4;
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar .main-nav a i {
    margin-right: 10px;
}

.sidebar .main-nav li.active a, .sidebar .main-nav a:hover {
    background-color: #1a2e4b;
    color: #ffffff;
    border-left: 4px solid #007bff;
}

.sidebar .user-profile {
    display: flex;
    align-items: center;
    padding: 20px 15px;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
    color: #e0e0e0;
    flex-shrink: 0;
}

.sidebar .user-profile span {
    font-size: 0.85em;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================
   4. COMPACT HORIZONTAL HEADER
   ========================================= */
.main-header {
    height: 60px;
    background-color: #1a1a2e;
    padding: 0 25px;
    border-bottom: 1px solid #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 5;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 50px;
    width: auto;
}

.header-text h1 {
    margin: 0;
    font-size: 0.95rem;
    color: #ffffff;
    white-space: nowrap;
}

.header-text h1 span {
    color: #87ceeb;
    font-weight: normal;
    font-size: 0.8rem;
    margin-left: 5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container i {
    position: absolute;
    left: 10px;
    color: #a0a7b4;
    font-size: 0.8rem;
}

.search-container input {
    padding: 6px 10px 6px 30px;
    background-color: #2c3e50;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #fff;
    width: 180px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions button {
    background: none;
    border: none;
    color: #a0a7b4;
    cursor: pointer;
    font-size: 1.1rem;
    position: relative;
}

/* Online Status Indicator */
.user-status-wrapper {
    position: relative;
    display: inline-block;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: #28a745;
    border: 2px solid #1a1a2e;
    border-radius: 50%;
}

/* =========================================
   5. DASHBOARD LAYOUT AND CARDS
   ========================================= */
.dashboard-layout {
    display: flex;
    padding: 15px;
    gap: 15px;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.card {
    background-color: #16213e;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: transform 0.2s;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #0f3460;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.card-header h2 {
    margin: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.expand-btn {
    background: none;
    border: none;
    color: #87ceeb;
    font-size: 1em;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    padding: 5px;
}

.expand-btn:hover {
    color: #4682b4;
    transform: scale(1.1);
}

/* =========================================
   6. SPECIFIC PANELS (CHAT AND METABASE)
   ========================================= */
.chat-panel {
    flex: 1;
    min-width: 320px;
}

.dashboard-panel {
    flex: 2.5;
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#embed-container {
    flex-grow: 1;
    width: 100%;
    position: relative;
    display: flex;
}

#dashboard-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0 0 8px 8px;
}

/* =========================================
   7. EXPANDED STATE (FULLSCREEN MODAL)
   ========================================= */
.card.expanded {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.card.expanded .card-header {
    border-radius: 0;
    padding: 15px 25px;
}

body.has-expanded {
    overflow: hidden;
}

/* =========================================
   8. CHAT COMPONENTS
   ========================================= */
.chat-message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.user-message {
    background-color: #007bff;
    align-self: flex-end;
}

.ai-message {
    background-color: #2c3e50;
    align-self: flex-start;
}

.chat-input-area {
    padding: 15px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #0f3460;
}

#user-input {
    flex-grow: 1;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 20px;
    padding: 8px 15px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#user-input::placeholder {
    color: #a0a7b4;
}

#user-input:focus {
    border-color: #007bff;
}

#send-button {
    padding: 8px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

#send-button:hover {
    background-color: #0056b3;
}

/* =========================================
   9. RESPONSIVE
   ========================================= */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 10px 0;
    }

    .sidebar .logo {
        height: 40px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .sidebar .main-nav,
    .sidebar .user-profile {
        display: none;
    }

    .main-content-wrapper {
        min-height: auto;
        flex-grow: 1;
    }

    .main-header {
        height: auto;
        padding: 10px 15px;
        flex-direction: column;
        gap: 10px;
    }

    .dashboard-layout {
        flex-direction: column;
        padding: 10px;
        overflow-y: auto;
    }

    .chat-panel, .dashboard-panel {
        min-width: unset;
        width: 100%;
        height: 500px;
        flex-shrink: 0;
    }
}
