/* ═══════════════════════════════════════════════════
   Siga-Me App v2 — Chat Interface Styles
   ═══════════════════════════════════════════════════ */

:root {
    --sky-top: #a8cce0;
    --sky-bottom: #e8f2f8;
    --bg: #ffffff;
    --surface: #f4f7f9;
    --text: #1e293b;
    --text-2: #475569;
    --text-muted: #94a3b8;
    --accent: #4a90c4;
    --accent-light: #e0f0ff;
    --user-bubble: #dcedfc;
    --gold: #b8964e;
    --gold-light: #f5eed8;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.06);
    --font-d: 'Cormorant Garamond', Georgia, serif;
    --font-b: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-full: 50%;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-b);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ─── App Container ────────────────────────────── */
#sigame-app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ═══ WELCOME SCREEN ═══════════════════════════ */
.sigame-welcome {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.sigame-welcome.leaving {
    opacity: 0;
    transform: translateY(-30px);
    pointer-events: none;
}

.sigame-welcome.gone {
    display: none;
}

.sigame-welcome-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 50%, #f8fbff 100%);
    z-index: 0;
}

.sigame-welcome-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('../img/bg-sky.jpg');
    background-size: cover;
    background-position: center top;
    opacity: 0.4;
    mix-blend-mode: soft-light;
}

.sigame-menu-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.6);
    border: none;
    border-radius: var(--r-full);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.sigame-menu-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

.sigame-welcome-content {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
    max-width: 480px;
    padding: 0 24px;
    animation: welcomeIn 0.8s var(--ease) both;
}

.sigame-greeting {
    font-family: var(--font-d);
    font-size: 3.5rem;
    font-weight: 300;
    color: var(--text);
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 40px rgba(74, 144, 196, 0.1);
}

.sigame-welcome-form {
    width: 100%;
}

.sigame-input {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font-b);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.85);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.sigame-input::placeholder {
    color: var(--text-muted);
}

.sigame-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 144, 196, 0.15);
    background: #fff;
}

.sigame-send-btn-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 12px;
    padding: 14px 24px;
    font-family: var(--font-b);
    font-size: 1rem;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 12px rgba(74, 144, 196, 0.25);
}

.sigame-send-btn-welcome:hover {
    background: #3d7db3;
}

.sigame-send-btn-welcome:active {
    transform: scale(0.98);
}

.sigame-send-btn-welcome.loading .sigame-send-text {
    display: none;
}

.sigame-send-btn-welcome .sigame-send-loading {
    display: none;
}

.sigame-send-btn-welcome.loading .sigame-send-loading {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sigame-send-btn-welcome.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* ═══ CHAT SCREEN ══════════════════════════════ */
.sigame-chat {
    display: none;
    flex-direction: column;
    height: 100vh;
}

.sigame-chat.active {
    display: flex;
}

/* Chat Header */
.sigame-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 5;
}

.sigame-chat-title {
    font-family: var(--font-d);
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--text);
    letter-spacing: 0.02em;
}

.sigame-chat-header-spacer {
    flex: 1;
}

.sigame-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--r-full);
    transition: background 0.2s;
}

.sigame-icon-btn:hover {
    background: var(--surface);
}

/* Messages Area */
.sigame-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ─── Message Bubbles ───────────────────────── */
.sigame-msg {
    display: flex;
    margin-bottom: 12px;
    animation: msgIn 0.35s var(--ease) both;
}

.sigame-msg-user {
    justify-content: flex-end;
}

.sigame-msg-ai {
    justify-content: flex-start;
}

.sigame-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 0.95rem;
    line-height: 1.65;
    word-break: break-word;
}

.sigame-msg-user .sigame-bubble {
    background: var(--user-bubble);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.sigame-msg-ai .sigame-bubble {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    padding: 0;
    overflow: hidden;
}

/* AI Response Sections */
.sigame-ai-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.sigame-ai-section:last-child {
    border-bottom: none;
}

.sigame-ai-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    margin-bottom: 8px;
}

.sigame-ai-label svg {
    flex-shrink: 0;
}

.sigame-ai-quote {
    font-family: var(--font-d);
    font-size: 1.15rem;
    font-style: italic;
    font-weight: 400;
    line-height: 1.55;
    padding-left: 12px;
    border-left: 2px solid var(--gold);
    color: var(--text);
}

.sigame-ai-ref {
    display: block;
    margin-top: 8px;
    font-family: var(--font-b);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gold);
    font-style: normal;
}

.sigame-ai-text {
    font-size: 0.92rem;
    font-weight: 400;
    color: var(--text-2);
    line-height: 1.7;
}

.sigame-ai-reflection {
    font-family: var(--font-d);
    font-size: 1.05rem;
    font-style: italic;
    color: var(--text);
    line-height: 1.6;
    background: linear-gradient(135deg, rgba(184, 150, 78, 0.06), transparent);
    border-radius: 0 0 var(--r-md) var(--r-md);
}

/* Message Actions */
.sigame-msg-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
}

.sigame-msg-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-family: var(--font-b);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all 0.2s;
}

.sigame-msg-action:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sigame-msg-action svg {
    flex-shrink: 0;
}

/* Typing Indicator */
.sigame-typing .sigame-bubble {
    padding: 14px 20px;
    border: 1px solid var(--border);
}

.sigame-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.sigame-dots span {
    width: 7px;
    height: 7px;
    border-radius: var(--r-full);
    background: var(--text-muted);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.sigame-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.sigame-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

/* ─── Input Bar ─────────────────────────────── */
.sigame-input-bar {
    flex-shrink: 0;
    padding: 8px 12px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.sigame-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.sigame-input-chat {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: var(--r-lg);
    font-size: 0.95rem;
}

.sigame-send-circle {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: var(--r-full);
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(74, 144, 196, 0.2);
}

.sigame-send-circle:hover {
    background: #3d7db3;
}

.sigame-send-circle:active {
    transform: scale(0.92);
}

.sigame-send-circle:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ═══ SIDEBAR ══════════════════════════════════ */
.sigame-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sigame-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.sigame-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 101;
    width: 300px;
    max-width: 85vw;
    background: #fff;
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.sigame-sidebar.open {
    transform: translateX(0);
}

.sigame-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sigame-sidebar-title {
    font-family: var(--font-d);
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--text);
}

.sigame-sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sigame-nav-item {
    display: block;
    width: 100%;
    padding: 14px 24px;
    font-family: var(--font-b);
    font-size: 0.92rem;
    font-weight: 400;
    color: var(--text);
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.sigame-nav-item:hover {
    background: var(--surface);
}

/* Sidebar Pages */
.sigame-sidebar-page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    padding: 0 24px 24px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s var(--ease);
    z-index: 5;
}

.sigame-sidebar-page.active {
    transform: translateX(0);
}

.sigame-sidebar-page h3 {
    font-family: var(--font-d);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text);
    margin: 0 0 16px;
}

.sigame-sidebar-page p {
    font-size: 0.9rem;
    color: var(--text-2);
    line-height: 1.7;
    margin-bottom: 12px;
}

.sigame-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 14px 0;
    margin-bottom: 8px;
    font-family: var(--font-b);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    background: transparent;
    border: none;
    cursor: pointer;
}

/* ═══ MODALS ═══════════════════════════════════ */
.sigame-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: modalBgIn 0.3s both;
}

@media(min-width:600px) {
    .sigame-modal {
        align-items: center;
    }
}

.sigame-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sigame-modal-content {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: var(--r-md) var(--r-md) 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalUp 0.35s var(--ease) both;
}

@media(min-width:600px) {
    .sigame-modal-content {
        border-radius: var(--r-md);
    }
}

.sigame-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.sigame-modal-header h2 {
    font-family: var(--font-d);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--text);
}

.sigame-modal-body {
    padding: 20px;
}

.sigame-modal-footer {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.sigame-btn-primary {
    flex: 1;
    padding: 12px;
    font-family: var(--font-b);
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.sigame-btn-primary:hover {
    background: #3d7db3;
}

.sigame-btn-outline {
    flex: 1;
    padding: 12px;
    font-family: var(--font-b);
    font-size: 0.9rem;
    font-weight: 500;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.sigame-btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Format Selector */
.sigame-format-sel {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 3px;
}

.sigame-fmt-btn {
    flex: 1;
    padding: 8px;
    font-family: var(--font-b);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all 0.2s;
}

.sigame-fmt-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Bg Selector */
.sigame-bg-sel {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.sigame-bg-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.sigame-bg-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 144, 196, 0.2);
}

/* Card Preview */
.sigame-card-preview {
    display: flex;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--r-sm);
    padding: 12px;
    min-height: 180px;
}

.sigame-card-preview canvas {
    max-width: 100%;
    max-height: 360px;
    border-radius: 6px;
}

/* Share Grid */
.sigame-share-content {
    max-width: 360px;
}

.sigame-share-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 20px;
}

.sigame-share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-b);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-2);
}

.sigame-share-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* ═══ TOAST ════════════════════════════════════ */
.sigame-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--text);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--r-lg);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s var(--ease);
    pointer-events: none;
    white-space: nowrap;
}

.sigame-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ═══ ANIMATIONS ═══════════════════════════════ */
@keyframes welcomeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

@keyframes dotPulse {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes modalBgIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

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

/* ═══ RESPONSIVE ═══════════════════════════════ */
@media(max-width:480px) {
    .sigame-greeting {
        font-size: 2.8rem;
    }

    .sigame-bubble {
        max-width: 90%;
    }

    .sigame-chat-header {
        padding: 8px 12px;
    }

    .sigame-messages {
        padding: 12px 12px 8px;
    }

    .sigame-input-bar {
        padding: 6px 10px;
    }

    .sigame-share-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .sigame-share-item {
        padding: 12px 6px;
    }
}

@media(min-width:769px) {
    .sigame-messages {
        max-width: 720px;
        margin: 0 auto;
        width: 100%;
    }

    .sigame-input-bar {
        max-width: 720px;
        margin: 0 auto;
        padding: 8px 0 12px;
    }

    .sigame-greeting {
        font-size: 4rem;
    }
}

/* Accessibility */
@media(prefers-reduced-motion:reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* WP Admin Bar */
.admin-bar .sigame-sidebar {
    top: 32px;
}

.admin-bar #sigame-app {
    height: calc(100vh - 32px);
}

@media(max-width:782px) {
    .admin-bar .sigame-sidebar {
        top: 46px;
    }

    .admin-bar #sigame-app {
        height: calc(100vh - 46px);
    }
}