/**
 * Lanika AI Frontend Dashboard Styles
 *
 * Additional styles for the frontend app dashboard
 * Extends lanika-dashboard.css
 */

/* ==========================================================================
   Frontend Dashboard - Full Screen Layout (No WP Admin)
   ========================================================================== */

html.lanika-app-html,
body.lanika-frontend-app {
    background: var(--lanika-bg-dark, #0d0f12) !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    overflow: hidden !important;
}

body.lanika-frontend-app .entry-content,
body.lanika-frontend-app .wp-block-post-content,
body.lanika-frontend-app .wp-site-blocks,
body.lanika-frontend-app .site,
body.lanika-frontend-app .site-content,
body.lanika-frontend-app .site-main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

/* ==========================================================================
   Frontend Dashboard Shell - Full Width
   ========================================================================== */

body.lanika-frontend-app .lanika-dashboard {
    position: fixed !important;
    inset: 0 !important;
    display: flex !important;
    min-height: 100vh !important;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 999999 !important;
    background: var(--lanika-bg-dark, #0d0f12) !important;
    box-sizing: border-box !important;
}

body.lanika-frontend-app .lanika-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: var(--lanika-sidebar-width, 240px) !important;
    z-index: 1000000 !important;
    flex-shrink: 0 !important;
}

body.lanika-frontend-app .lanika-main {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: var(--lanika-sidebar-width, 240px) !important;
    margin: 0 !important;
    padding: 32px 40px !important;
    height: 100% !important;
    width: calc(100% - var(--lanika-sidebar-width, 240px)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--lanika-bg-base, #12151a) !important;
    box-sizing: border-box !important;
}

body.lanika-frontend-app .lanika-main > * {
    min-width: 0;
}

body.lanika-frontend-app .lanika-grid,
body.lanika-frontend-app .lanika-card,
body.lanika-frontend-app .lanika-metric {
    min-width: 0;
}

body.lanika-frontend-app .lanika-card__body {
    overflow-x: auto;
}

/* ==========================================================================
   Metrics Grid - Full Width Horizontal Layout
   ========================================================================== */

body.lanika-frontend-app .lanika-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
    width: 100%;
}

body.lanika-frontend-app .lanika-metric {
    min-width: 0;
}

body.lanika-frontend-app .lanika-metric__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lanika-text-muted, #64748b);
    margin-bottom: 8px;
}

body.lanika-frontend-app .lanika-metric__value {
    font-size: 28px;
    font-weight: 700;
    color: var(--lanika-text-primary, #f1f5f9);
    margin-bottom: 8px;
    line-height: 1.2;
}

body.lanika-frontend-app .lanika-metric__change {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

body.lanika-frontend-app .lanika-metric__change--positive {
    background: var(--lanika-success-muted, rgba(34, 197, 94, 0.15));
    color: var(--lanika-success, #22c55e);
}

/* ==========================================================================
   Main Grid Layout - Full Width
   ========================================================================== */

body.lanika-frontend-app .lanika-grid--main-sidebar {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    width: 100%;
}

body.lanika-frontend-app .lanika-grid--2-col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* ==========================================================================
   Cards - Full Width
   ========================================================================== */

body.lanika-frontend-app .lanika-card {
    width: 100%;
}

/* ==========================================================================
   Fullpage Chat Styles
   ========================================================================== */

.lanika-fullpage-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px);
    min-height: 500px;
    background: var(--lanika-bg-surface, #1a1e25);
    border-radius: var(--lanika-radius-md, 10px);
    overflow: hidden;
}

.lanika-fullpage-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lanika-fullpage-chat__messages::-webkit-scrollbar {
    width: 6px;
}

.lanika-fullpage-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.lanika-fullpage-chat__messages::-webkit-scrollbar-thumb {
    background: var(--lanika-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 3px;
}

.lanika-fullpage-chat__message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--lanika-radius-md, 10px);
    line-height: 1.6;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.lanika-fullpage-chat__message--user {
    align-self: flex-end;
    background: var(--lanika-accent-primary, #3b82f6);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.lanika-fullpage-chat__message--assistant {
    align-self: flex-start;
    background: var(--lanika-bg-surface-elevated, #252b35);
    color: var(--lanika-text-primary, #f1f5f9);
    border-bottom-left-radius: 4px;
}

.lanika-fullpage-chat__status {
    padding: 8px 24px;
    font-size: 13px;
    color: var(--lanika-text-muted, #64748b);
    min-height: 32px;
}

.lanika-fullpage-chat__footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--lanika-border-subtle, rgba(255, 255, 255, 0.06));
    background: var(--lanika-bg-surface, #1a1e25);
}

.lanika-fullpage-chat__input {
    flex: 1;
    resize: none;
    min-height: 48px;
    max-height: 120px;
}

.lanika-fullpage-chat__send {
    align-self: flex-end;
    min-width: 100px;
}

.lanika-fullpage-chat--loading .lanika-fullpage-chat__input,
.lanika-fullpage-chat--loading .lanika-fullpage-chat__send {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   Frontend Toggle Component
   ========================================================================== */

.lanika-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.lanika-toggle input {
    display: none;
}

.lanika-toggle__slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--lanika-bg-surface-elevated, #252b35);
    border-radius: 12px;
    transition: background 200ms ease;
    flex-shrink: 0;
}

.lanika-toggle__slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--lanika-text-muted, #64748b);
    border-radius: 50%;
    transition: all 200ms ease;
}

.lanika-toggle input:checked + .lanika-toggle__slider {
    background: var(--lanika-accent-primary, #3b82f6);
}

.lanika-toggle input:checked + .lanika-toggle__slider::after {
    left: 23px;
    background: #ffffff;
}

.lanika-toggle__label {
    color: var(--lanika-text-secondary, #94a3b8);
    font-size: 14px;
}

/* ==========================================================================
   Empty State Component
   ========================================================================== */

.lanika-empty {
    text-align: center;
    padding: 48px 24px;
}

.lanika-empty__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--lanika-text-muted, #64748b);
}

.lanika-empty__icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.lanika-empty__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--lanika-text-primary, #f1f5f9);
    margin: 0 0 8px;
}

.lanika-empty__description {
    font-size: 14px;
    color: var(--lanika-text-muted, #64748b);
    margin: 0 0 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================================================
   Header Avatar
   ========================================================================== */

.lanika-header__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--lanika-accent-primary, #3b82f6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ==========================================================================
   Popup Chat Floating Action Button
   ========================================================================== */

.lanika-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
}

.lanika-chat-fab__button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--lanika-accent-primary, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--lanika-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.5));
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.lanika-chat-fab__button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

.lanika-chat-fab__button--pulse {
    animation: lanika-pulse 2s infinite;
}

@keyframes lanika-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.lanika-chat-fab__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* ==========================================================================
   Popup Chat Panel
   ========================================================================== */

.lanika-popup-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--lanika-bg-surface, #1a1e25);
    border-radius: var(--lanika-radius-lg, 16px);
    border: 1px solid var(--lanika-border-default, rgba(255, 255, 255, 0.1));
    box-shadow: var(--lanika-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.5));
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
}

.lanika-popup-chat--open {
    display: flex;
}

.lanika-popup-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--lanika-border-subtle, rgba(255, 255, 255, 0.06));
    background: var(--lanika-bg-surface-elevated, #252b35);
}

.lanika-popup-chat__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--lanika-text-primary, #f1f5f9);
}

.lanika-popup-chat__actions {
    display: flex;
    gap: 8px;
}

.lanika-popup-chat__new,
.lanika-popup-chat__close {
    background: var(--lanika-bg-surface, #1a1e25);
    border: 1px solid var(--lanika-border-default, rgba(255, 255, 255, 0.1));
    color: var(--lanika-text-secondary, #94a3b8);
    padding: 6px 12px;
    border-radius: var(--lanika-radius-sm, 6px);
    font-size: 12px;
    cursor: pointer;
    transition: all 150ms ease;
}

.lanika-popup-chat__new:hover,
.lanika-popup-chat__close:hover {
    background: var(--lanika-bg-surface-hover, #22272f);
    color: var(--lanika-text-primary, #f1f5f9);
}

.lanika-popup-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
}

.lanika-popup-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.lanika-popup-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.lanika-popup-chat__messages::-webkit-scrollbar-thumb {
    background: var(--lanika-border-default, rgba(255, 255, 255, 0.1));
    border-radius: 2px;
}

.lanika-popup-chat__message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--lanika-radius-md, 10px);
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.lanika-popup-chat__message--user {
    align-self: flex-end;
    background: var(--lanika-accent-primary, #3b82f6);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.lanika-popup-chat__message--assistant {
    align-self: flex-start;
    background: var(--lanika-bg-surface-elevated, #252b35);
    color: var(--lanika-text-primary, #f1f5f9);
    border-bottom-left-radius: 4px;
}

.lanika-popup-chat__status {
    padding: 4px 16px;
    font-size: 12px;
    color: var(--lanika-text-muted, #64748b);
    min-height: 24px;
}

.lanika-popup-chat__footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--lanika-border-subtle, rgba(255, 255, 255, 0.06));
    background: var(--lanika-bg-surface, #1a1e25);
}

.lanika-popup-chat__input {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 80px;
    font-size: 14px;
}

.lanika-popup-chat__send {
    align-self: flex-end;
    padding: 8px 16px;
    font-size: 14px;
}

.lanika-popup-chat--loading .lanika-popup-chat__input,
.lanika-popup-chat--loading .lanika-popup-chat__send {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.lanika-flex {
    display: flex;
}

.lanika-flex-col {
    flex-direction: column;
}

.lanika-gap-12 {
    gap: 12px;
}

.lanika-gap-16 {
    gap: 16px;
}

.lanika-gap-24 {
    gap: 24px;
}

.lanika-mb-16 {
    margin-bottom: 16px;
}

.lanika-mb-24 {
    margin-bottom: 24px;
}

.lanika-mt-16 {
    margin-top: 16px;
}

.lanika-text-lg {
    font-size: 18px;
}

.lanika-text-sm {
    font-size: 13px;
}

.lanika-text-muted {
    color: var(--lanika-text-muted, #64748b);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Large screens */
@media (min-width: 1400px) {
    body.lanika-frontend-app .lanika-main {
        padding: 40px 60px !important;
    }

    body.lanika-frontend-app .lanika-grid--main-sidebar {
        grid-template-columns: 1fr 420px;
    }
}

/* Medium screens */
@media (max-width: 1200px) {
    body.lanika-frontend-app .lanika-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    body.lanika-frontend-app .lanika-grid--main-sidebar {
        grid-template-columns: 1fr;
    }
}

/* Tablets */
@media (max-width: 992px) {
    body.lanika-frontend-app .lanika-sidebar {
        width: 200px !important;
    }

    body.lanika-frontend-app .lanika-main {
        left: 200px !important;
        width: calc(100vw - 200px) !important;
        padding: 24px 32px !important;
    }

    body.lanika-frontend-app .lanika-grid--2-col {
        grid-template-columns: 1fr;
    }
}

/* Mobile - Sidebar becomes top nav */
@media (max-width: 768px) {
    body.lanika-frontend-app .lanika-dashboard {
        flex-direction: column !important;
    }

    body.lanika-frontend-app .lanika-sidebar {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        bottom: auto !important;
        width: 100% !important;
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid var(--lanika-border-subtle, rgba(255, 255, 255, 0.06)) !important;
    }

    body.lanika-frontend-app .lanika-sidebar__nav {
        max-height: none;
        overflow: visible;
        padding: 8px 12px;
    }

    body.lanika-frontend-app .lanika-sidebar__logo {
        padding: 12px 16px;
    }

    body.lanika-frontend-app .lanika-sidebar__menu {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    body.lanika-frontend-app .lanika-sidebar__menu-item {
        margin-bottom: 0;
    }

    body.lanika-frontend-app .lanika-sidebar__menu-link {
        padding: 8px 12px;
    }

    body.lanika-frontend-app .lanika-sidebar__menu-text {
        display: none;
    }

    body.lanika-frontend-app .lanika-sidebar__footer {
        display: none;
    }

    body.lanika-frontend-app .lanika-main {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        margin-left: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: calc(100vh - 120px) !important;
        padding: 20px 16px !important;
        flex: 1 !important;
    }

    body.lanika-frontend-app .lanika-metrics {
        grid-template-columns: 1fr;
    }

    .lanika-fullpage-chat {
        height: calc(100vh - 280px);
        min-height: 400px;
    }

    .lanika-popup-chat {
        width: calc(100% - 32px);
        right: 16px;
        left: 16px;
        bottom: 80px;
        max-height: 70vh;
    }

    .lanika-chat-fab {
        bottom: 16px;
        right: 16px;
    }

    .lanika-chat-fab__button {
        width: 52px;
        height: 52px;
    }

    .lanika-chat-fab__icon {
        width: 30px;
        height: 30px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    body.lanika-frontend-app .lanika-main {
        padding: 16px 12px !important;
    }

    body.lanika-frontend-app .lanika-header__title {
        font-size: 22px;
    }

    body.lanika-frontend-app .lanika-metric__value {
        font-size: 22px;
    }

    .lanika-fullpage-chat__message {
        max-width: 90%;
    }
}
