.app-ai-assistant {
    position: fixed;
    right: 18px;
    bottom: 76px;
    z-index: 1400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.has-global-footer {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.has-global-footer > .app-shell,
body.has-global-footer > .container,
body.has-global-footer > main,
body.has-global-footer > .main-content {
    flex: 1 0 auto;
}

.app-ai-panel[hidden] {
    display: none !important;
}

.app-ai-toggle {
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    color: #fff;
    font-weight: 700;
    padding: 12px 22px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(15, 76, 129, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-ai-toggle i {
    font-size: 1.05rem;
}

.app-ai-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15, 76, 129, 0.42);
}

.app-ai-toggle:active {
    transform: translateY(0);
}

.app-ai-toggle.app-ai-pulse {
    animation: appAiPulse 1.2s ease-in-out 6;
}

@keyframes appAiPulse {
    0% { transform: scale(1); box-shadow: 0 10px 25px rgba(15, 76, 129, 0.3); }
    50% { transform: scale(1.06); box-shadow: 0 14px 30px rgba(15, 76, 129, 0.45); }
    100% { transform: scale(1); box-shadow: 0 10px 25px rgba(15, 76, 129, 0.3); }
}

.app-ai-panel {
    position: absolute;
    right: 0;
    bottom: 60px;
    width: min(380px, calc(100vw - 28px));
    max-height: min(78vh, 650px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.05);
    animation: panelSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

[data-theme="dark"] .app-ai-panel {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

@keyframes panelSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.app-ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-ai-header strong {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.app-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-ai-clear {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.app-ai-clear:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: #ffffff;
}

.app-ai-close {
    border: 0;
    background: transparent;
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
    padding: 0 4px;
}

.app-ai-close:hover {
    color: #ffffff;
}

.app-ai-messages {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

[data-theme="dark"] .app-ai-messages {
    background: #0f172a;
}

.app-ai-user-msg,
.app-ai-bot-msg {
    max-width: 85%;
    border-radius: 16px;
    padding: 10px 14px;
    line-height: 1.45;
    font-size: 0.92rem;
    white-space: pre-wrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.app-ai-user-msg {
    margin-left: auto;
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.app-ai-bot-msg {
    margin-right: auto;
    background: #ffffff;
    color: var(--text, #1e293b);
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

[data-theme="dark"] .app-ai-bot-msg {
    background: #1e293b;
    color: #f8fafc;
    border-color: #334155;
}

.app-ai-bot-msg.app-ai-streaming::after {
    content: '|';
    margin-left: 2px;
    opacity: 0.8;
    animation: appAiCaretBlink 0.9s steps(2, end) infinite;
}

@keyframes appAiCaretBlink {
    0% { opacity: 0; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

.app-ai-bot-msg.app-ai-typing {
    opacity: 0.85;
    font-style: italic;
    background: #f1f5f9;
}

[data-theme="dark"] .app-ai-bot-msg.app-ai-typing {
    background: #1e293b;
}

.app-ai-bot-msg.app-ai-typing::after {
    content: '...';
    display: inline-block;
    width: 16px;
    overflow: hidden;
    vertical-align: bottom;
    animation: appAiDots 1.2s steps(4, end) infinite;
}

@keyframes appAiDots {
    0% { width: 0; }
    100% { width: 16px; }
}

.app-ai-feedback {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.app-ai-feedback-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

[data-theme="dark"] .app-ai-feedback-btn {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}

.app-ai-feedback-btn.active {
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.2);
}

.app-ai-feedback-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.app-ai-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

[data-theme="dark"] .app-ai-quick {
    background: #1e293b;
    border-color: #334155;
}

.app-ai-quick-label {
    width: 100%;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

[data-theme="dark"] .app-ai-quick-label {
    color: #94a3b8;
}

.app-ai-quick button {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: var(--text, #1e293b);
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .app-ai-quick button {
    background: #0f172a;
    border-color: #475569;
    color: #cbd5e1;
}

.app-ai-quick button:hover {
    border-color: var(--brand, #0f4c81);
    background: rgba(15, 76, 129, 0.05);
    color: var(--brand, #0f4c81);
    transform: translateY(-1px);
}

.app-ai-fix-snippet {
    margin-top: 8px;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .app-ai-fix-snippet {
    background: #0f172a;
    border-color: #334155;
}

.app-ai-fix-snippet pre {
    margin: 0;
    padding: 10px 12px;
    font-family: Consolas, "Liberation Mono", Courier, monospace;
    font-size: 0.76rem;
    color: #0f172a;
    max-height: 140px;
    overflow: auto;
    white-space: pre-wrap;
}

[data-theme="dark"] .app-ai-fix-snippet pre {
    color: #e2e8f0;
}

.app-ai-fix-copy {
    border: 0;
    border-top: 1px solid #dbe4ef;
    background: #f1f5f9;
    color: var(--brand, #0f4c81);
    width: 100%;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

[data-theme="dark"] .app-ai-fix-copy {
    background: #1e293b;
    border-color: #334155;
    color: #38bdf8;
}

.app-ai-fix-copy:hover {
    background: #e2e8f0;
}

[data-theme="dark"] .app-ai-fix-copy:hover {
    background: #334155;
}

.app-ai-form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    padding: 12px;
    background: #ffffff;
    align-items: center;
}

[data-theme="dark"] .app-ai-form {
    background: #1e293b;
    border-color: #334155;
}

.app-ai-mode {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 9px 10px;
    min-width: 110px;
    background: #f8fafc;
    color: var(--text, #1e293b);
    font-size: 0.86rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

[data-theme="dark"] .app-ai-mode {
    background: #0f172a;
    border-color: #475569;
    color: #f8fafc;
}

.app-ai-mode:focus {
    border-color: var(--brand, #0f4c81);
}

.app-ai-form input {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 9px 12px;
    outline: none;
    font-size: 0.88rem;
    transition: all 0.2s;
}

[data-theme="dark"] .app-ai-form input {
    background: #0f172a;
    border-color: #475569;
    color: #f8fafc;
}

.app-ai-form input:focus {
    border-color: var(--brand, #0f4c81);
    box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

.app-ai-form button {
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    color: #fff;
    padding: 9px 16px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.app-ai-form button:hover {
    opacity: 0.9;
}

.app-ai-smart-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.app-ai-smart-link {
    display: inline-flex;
    align-items: center;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 5px 12px;
    text-decoration: none;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}

[data-theme="dark"] .app-ai-smart-link {
    background: rgba(30, 64, 175, 0.2);
    border-color: rgba(30, 64, 175, 0.4);
    color: #60a5fa;
}

.app-ai-smart-link:hover {
    background: #dbeafe;
    transform: translateY(-0.5px);
}

.app-alert-fab {
    position: fixed;
    right: 18px;
    bottom: 132px;
    z-index: 1401;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #1e3a8a;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(2, 12, 28, 0.3);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.app-alert-fab i {
    font-size: 1.05rem;
}

.app-alert-fab:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(2, 12, 28, 0.35);
}

.app-alert-fab.has-alerts {
    background: #ef4444;
    border-color: #f87171;
}

.app-alert-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 0.72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

@media (max-width: 720px) {
    .app-ai-assistant {
        right: 10px;
        bottom: 84px;
    }
    .app-alert-fab {
        right: 10px;
        bottom: 140px;
    }
    .app-ai-panel {
        width: min(95vw, 380px);
        max-height: 75vh;
    }
}

.app-global-footer {
    position: relative;
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 220px 8px 14px;
    background: rgba(15, 23, 42, 0.94);
    color: #e2e8f0;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    font-size: 0.82rem;
}

.app-global-footer-left,
.app-global-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: 0;
}

.app-global-footer-brand {
    font-weight: 700;
    color: #f8fafc;
}

.app-global-footer-sep {
    color: #94a3b8;
}

.app-global-footer a {
    color: #c7d2fe;
    text-decoration: none;
    font-weight: 600;
}

.app-global-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .app-global-footer {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px 10px;
    }
}

.app-welcome-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1500;
    padding: 12px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand, #0f4c81) 0%, var(--brand-2, #1f7a8c) 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(15, 76, 129, 0.25);
    animation: appWelcomeFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-welcome-toast.app-welcome-hide {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

@keyframes appWelcomeFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
