/* ========================================================
   AskFoxy - Dedicated Q&A History Page Stylesheet
   ======================================================== */

:root {
    --primary-orange: #f39c12;
    --primary-dark: #d35400;
    --primary-amber: #e67e22;
    --bg-sky: #74b9ff;
    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --accent-green: #10b981;
    --accent-blue: #0284c7;
    --border-light: #e2e8f0;
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-float: 0 8px 20px -4px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Fredoka', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #74b9ff 0%, #a29bfe 100%);
    background-attachment: fixed;
    color: var(--text-dark);
    min-height: 100vh;
    min-height: 100dvh;
    min-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    padding: 16px 12px max(16px, env(safe-area-inset-bottom, 0px), var(--safe-bottom, 0px));
}

/* Top Sticky Navigation Bar */
.history-nav {
    position: sticky;
    top: 10px;
    z-index: 100;
    max-width: 760px;
    width: 100%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 2px solid #ffd700;
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    box-shadow: var(--shadow-float);
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff8e7;
    color: var(--primary-dark);
    border: 2px solid var(--primary-orange);
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-back-home:hover {
    background: var(--primary-orange);
    color: #ffffff;
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 16px rgba(243, 156, 18, 0.3);
}

.btn-back-home:active {
    transform: scale(0.96);
}

.history-nav-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #2f3542;
}

.history-nav-title i {
    color: var(--primary-orange);
    font-size: 1.3rem;
}

.history-count-pill {
    background: #eef2f7;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 16px;
    white-space: nowrap;
    border: 1px solid var(--border-light);
}

/* Main Container Card */
.history-container {
    max-width: 760px;
    width: 100%;
    margin: 0 auto 20px;
    background: #ffffff;
    border-radius: 24px;
    padding: 20px 22px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 0 1 auto;
}

/* Search Toolbar - Sticky below top nav */
.history-toolbar {
    position: sticky;
    top: 76px;
    z-index: 80;
    background: #ffffff;
    padding: 6px 0 10px;
    margin-top: -6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffdf5;
    border: 2px solid #ffd700;
    border-radius: 16px;
    padding: 10px 16px;
    transition: all 0.2s ease;
}

.history-search-box:focus-within {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.2);
    background: #ffffff;
}

.history-search-box .search-icon {
    color: var(--primary-orange);
    font-size: 1rem;
}

.history-search-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    color: #2d3436;
}

.btn-search-clear {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.btn-search-clear:hover {
    color: #e74c3c;
}

/* Stream Container */
.history-stream-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 300px;
}

/* History Card */
.history-card {
    background: #ffffff;
    border: 2px solid #f1f2f6;
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.22s ease;
}

.history-card:hover {
    border-color: #ffd700;
    box-shadow: 0 8px 22px rgba(246, 185, 59, 0.18);
    transform: translateY(-2px);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 1px dashed #f1f2f6;
}

.history-timestamp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.history-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-tier-badge {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.74rem;
    padding: 3px 9px;
    border-radius: 8px;
    font-weight: 700;
    border: 1px solid #e2e8f0;
}

.history-web-badge {
    background: #e0f2fe;
    color: #0284c7;
    font-size: 0.74rem;
    padding: 3px 9px;
    border-radius: 8px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #bae6fd;
}

/* Message Rows */
.history-msg-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.history-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.child-msg .history-msg-avatar {
    background: #fff8e7;
    color: var(--primary-orange);
    border: 2px solid #ffeaa7;
}

.fox-msg .history-msg-avatar {
    background: #eafffc;
    color: #0abde3;
    border: 2px solid #c7ecee;
}

.history-msg-bubble {
    flex: 1;
    min-width: 0;
}

.history-bubble-sender {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 3px;
}

.history-bubble-text {
    font-size: 0.96rem;
    line-height: 1.5;
    color: #1e293b;
    word-break: break-word;
}

.history-bubble-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn-replay-audio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8f8f0;
    color: #27ae60;
    border: 1.5px solid #2ecc71;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-replay-audio:hover {
    background: #27ae60;
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-replay-audio:active {
    transform: scale(0.96);
}

.btn-replay-audio.playing {
    background: #27ae60;
    color: #ffffff;
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Empty & Loading States */
.history-empty-state {
    text-align: center;
    padding: 50px 16px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.history-empty-state i {
    font-size: 3rem;
    color: #fbc531;
}

.history-empty-state h3 {
    color: #2f3542;
    font-size: 1.2rem;
}

.history-empty-state p {
    font-size: 0.95rem;
    max-width: 400px;
    line-height: 1.5;
}

.history-loading-spinner {
    text-align: center;
    padding: 40px 16px;
    color: #747d8c;
    font-size: 1rem;
    font-weight: 700;
}

/* ========================================================
   Application Footer (VAapps Brand & Version Attribution)
   ======================================================== */
.app-footer {
    text-align: center;
    padding: 6px 16px;
    margin-top: auto;
    margin-bottom: max(12px, env(safe-area-inset-bottom, 0px), var(--safe-bottom, 0px));
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    align-self: center;
    z-index: 10;
}

.footer-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    font-size: 0.72rem;
    color: #475569;
}

.vaapps-link {
    color: #4338ca;
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: 0.76rem;
    transition: transform 0.2s ease;
}

.vaapps-link:hover {
    transform: translateY(-1px);
}

.footer-brand {
    font-weight: 800;
    color: #4338ca;
    letter-spacing: -0.2px;
    font-size: 0.78rem;
}

.footer-by {
    font-weight: 600;
    color: #6366f1;
    font-size: 0.72rem;
}

.footer-vaapps {
    font-weight: 800;
    color: #4338ca;
    position: relative;
    display: inline-block;
    padding-bottom: 2px;
    letter-spacing: -0.2px;
    font-size: 0.78rem;
}

.footer-vaapps::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1.8px;
    border-radius: 2px;
    background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 25%, #d946ef 50%, #ec4899 75%, #4f46e5 100%);
    background-size: 200% 100%;
    animation: vaappsGradientSlide 3s linear infinite;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.45);
}

.vaapps-link:hover .footer-vaapps::after {
    height: 2.2px;
    box-shadow: 0 2px 8px rgba(217, 70, 239, 0.6);
}

@keyframes vaappsGradientSlide {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

.footer-sep {
    color: #94a3b8;
    font-size: 0.70rem;
    user-select: none;
}

.footer-version {
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.65rem;
    letter-spacing: 0.3px;
    border: 1px solid rgba(211, 84, 0, 0.25);
    box-shadow: 0 1px 4px rgba(230, 126, 34, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.footer-copy {
    color: #64748b;
    font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    body {
        padding: 10px 8px max(14px, env(safe-area-inset-bottom, 0px), var(--safe-bottom, 0px));
    }

    .history-nav {
        top: 6px;
        padding: 8px 12px;
        margin: 0 auto 12px;
    }

    .history-nav-title span {
        display: none;
    }

    .history-toolbar {
        top: 56px;
        padding: 4px 0 8px;
        margin-top: -4px;
        background: #ffffff;
    }

    .history-container {
        padding: 16px 12px;
        border-radius: 18px;
        margin: 0 auto 16px;
    }

    .btn-back-home {
        padding: 6px 12px;
        font-size: 0.84rem;
    }

    .app-footer {
        padding: 6px 14px;
        margin-top: auto;
        margin-bottom: max(10px, env(safe-area-inset-bottom, 0px), var(--safe-bottom, 0px));
        border-radius: 16px;
        max-width: 95%;
    }

    .footer-content {
        font-size: 0.76rem;
        gap: 6px;
    }

    .vaapps-link {
        font-size: 0.82rem;
    }

    .footer-brand,
    .footer-vaapps {
        font-size: 0.86rem;
    }

    .footer-version {
        font-size: 0.66rem;
        padding: 1px 6px;
    }
}
