/* Fily Admin Design System - RecoMaster */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-sidebar: #282C3C;
    --bg-canvas: #F2F2F9;
    --bg-surface: #FFFFFF;

    --text-heading: #343a40;
    --text-body: #6C7293;
    --text-sidebar-active: #FFFFFF;
    --text-sidebar-muted: #8D94AD;

    --brand-blue: #0090E7;
    --brand-green: #00D25B;
    --brand-amber: #FFAB00;
    --brand-red: #FC424A;
    --brand-dark: #000000;

    --radius-card: 16px;
    --radius-btn: 6px;

    --sidebar-width: 260px;
    --navbar-height: 70px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-canvas);
    color: var(--text-body);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-heading);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

/* LAYOUT STRUCTURE */
.container-scroller {
    display: flex;
    overflow: hidden;
    width: 100%;
    min-height: 100vh;
    flex-direction: column;
    /* Vertical stacked */
}

/* Page Body Wrapper */
.page-body-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-left: 0;
}

/* Top Navbar */
.navbar-top {
    height: var(--navbar-height);
    background: #ffffff;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 1px 15px rgba(0, 0, 0, 0.04);
    z-index: 100;
    position: relative;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-body);
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--brand-blue) !important;
}

/* Main Panel */
.main-panel {
    flex-grow: 1;
    overflow-y: auto;
    background: var(--bg-canvas);
    display: flex;
    flex-direction: column;
}

/* CARDS */
.card {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-card);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.03);
    margin-bottom: 1.5rem;
}

.card-title {
    color: var(--text-heading);
    font-weight: 600;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Solid Stat Cards */
.card-stat {
    border-radius: var(--radius-card);
    color: white;
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-stat h3 {
    color: white;
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.card-stat p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.card-stat .icon-box {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 3.5rem;
}

.bg-gradient-primary {
    background: linear-gradient(to right, #0090E7, #007ac1);
}

.bg-gradient-success {
    background: linear-gradient(to right, #00D25B, #00b850);
}

.bg-gradient-danger {
    background: linear-gradient(to right, #FC424A, #e83e45);
}

.bg-gradient-warning {
    background: linear-gradient(to right, #FFAB00, #e69a00);
}

/* BUTTONS */
.btn {
    border-radius: var(--radius-btn);
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--brand-blue);
    border: none;
}

.btn-primary:hover {
    background: #007ac1;
    box-shadow: 0 4px 12px rgba(0, 144, 231, 0.3);
}

.btn-success {
    background: var(--brand-green);
    border: none;
    color: white;
}

.btn-danger {
    background: var(--brand-red);
    border: none;
    color: white;
}

/* FORMS */
.form-control,
.form-select {
    background: #2A3038;
    /* Fily usually has dark mode inputs, but guidelines said Light Canvas. */
    /* Adjusting to match Light Canvas theme but keep inputs modern */
    background: #FFFFFF;
    border: 1px solid #ebedf2;
    color: var(--text-heading);
    border-radius: 4px;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
}

.form-control:focus {
    border-color: var(--brand-blue);
    box-shadow: none;
}

/* TABLE */
.table th {
    border-top: none;
    border-bottom: 1px solid #ebedf2;
    color: #343a40;
    font-weight: 700;
    font-size: 0.85rem;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--text-body);
    border-bottom: 1px solid #ebedf2;
    padding: 1rem 0.75rem;
}

/* Badge */
.badge {
    border-radius: 4px;
    font-weight: 600;
    padding: 0.4em 0.8em;
}

.badge-opacity-success {
    background: rgba(0, 210, 91, 0.2);
    color: #00d25b;
    border: 1px solid rgba(0, 210, 91, 0.2);
}

.badge-opacity-primary {
    background: rgba(0, 144, 231, 0.2);
    color: #0090e7;
    border: 1px solid rgba(0, 144, 231, 0.2);
}

/* AGENT OVERLAY */
.agent-loader-card {
    background: #FFFFFF;
    color: var(--text-heading);
    border-radius: 12px;
}

#agent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(242, 242, 249, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

#agent-overlay.active {
    display: flex;
}

/* Media Queries */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 999;
    }

    .sidebar.active {
        left: 0;
    }

    .page-body-wrapper {
        width: 100%;
        margin-left: 0;
    }
}

/* CHAT INTERFACE */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height) - 40px);
    background: white;
    border-radius: var(--radius-card);
    overflow: hidden;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chat-message {
    max-width: 80%;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--brand-blue);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: #F4F5F7;
    color: var(--text-heading);
    border-bottom-left-radius: 2px;
}

.chat-input-area {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid #ebedf2;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input-area textarea {
    resize: none;
    border-radius: 24px;
    padding: 12px 20px;
    border: 1px solid #dee2e6;
    background-color: #f8f9fa;
    width: 100%;
    max-height: 120px;
    transition: all 0.2s;
}

.chat-input-area textarea:focus {
    background-color: white;
    box-shadow: 0 0 0 3px rgba(0, 144, 231, 0.1);
    outline: none;
    border-color: var(--brand-blue);
}

/* Inline Product Cards */
.chat-products-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    margin-top: 1rem;
    scrollbar-width: thin;
}

.product-mini-card {
    min-width: 220px;
    width: 220px;
    border: 1px solid #eee;
    background: white;
    border-radius: 8px;
    padding: 10px;
    transition: transform 0.2s;
    cursor: pointer;
}

.product-mini-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.product-mini-card img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 8px;
}

.product-mini-card h6 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-mini-card .price {
    font-weight: 700;
    color: var(--brand-green);
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* SPLIT VIEW LAYOUT */
.split-wrapper {
    display: flex;
    height: calc(100vh - var(--navbar-height));
    /* Top Nav still exists? Or remove header totally? RecoMaster has top nav... */
    /* Assuming Main Navbar exists above */
    overflow: hidden;
    background: #f8f9fa;
}

/* LEFT PANEL: Chat */
.chat-panel {
    width: 380px;
    min-width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid #ebedf2;
    height: 100%;
    z-index: 10;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.03);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #ebedf2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.chat-stream {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #ffffff;
}

.chat-stream .message {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 90%;
}

.chat-stream .message.user {
    align-self: flex-end;
    background: var(--brand-blue);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-stream .message.ai {
    align-self: flex-start;
    background: #F4F5F7;
    color: #333;
    border-bottom-left-radius: 2px;
}

/* Suggestions Chips */
.suggestions-wrapper {
    padding: 0.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.suggestion-chip {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    background: #F2F2F9;
    color: var(--text-heading);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.suggestion-chip:hover {
    background: #e2e2e9;
    border-color: #d0d0d8;
}

.chat-footer {
    padding: 1rem;
    background: white;
    border-top: 1px solid #ebedf2;
}

/* RIGHT PANEL: Results */
.results-panel {
    flex-grow: 1;
    min-width: 0;
    /* CRITICAL FIX: Allows grid to shrink properly */
    padding: 2rem;
    overflow-y: auto;
    background: #F8F9FA;
}

.results-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

/* Product Card (Grid) */
.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #eee;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    padding: 1rem;
    background: #fff;
    border-bottom: 1px solid #f9f9f9;
}

.product-card .body {
    padding: 1rem;
}

.product-card h6 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card .price {
    font-weight: 700;
    color: var(--brand-green);
    font-size: 1.1rem;
}

.product-card .meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.5rem;
}