/* Customer portal styles (on top of Pico CSS) */

/* Stat cards grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-card .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    margin-top: 0.25rem;
}

/* Tier badges */
.badge {
    display: inline-block;
    padding: 0.15em 0.55em;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-free       { background: #f1f5f9; color: #64748b; }
.badge-trial      { background: #e2e8f0; color: #475569; }
.badge-pro        { background: #dbeafe; color: #1d4ed8; }
.badge-enterprise { background: #fef3c7; color: #92400e; }

/* Status badges */
.badge-completed { background: #dcfce7; color: #166534; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-pending   { background: #e2e8f0; color: #475569; }
.badge-failed    { background: #fee2e2; color: #991b1b; }

/* Storage usage bar */
.storage-bar-wrapper {
    margin-bottom: 1.5rem;
}

.storage-bar-wrapper .storage-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.storage-bar {
    width: 100%;
    height: 12px;
    background: var(--pico-muted-border-color);
    border-radius: 6px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 6px;
    transition: width 0.3s ease;
}

.storage-bar-fill.warn  { background: #f59e0b; }
.storage-bar-fill.danger { background: #ef4444; }

/* Flash messages */
.msg-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: var(--pico-border-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.msg-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--pico-border-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

/* Workspace cards */
.workspace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.workspace-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.workspace-card:hover {
    border-color: var(--pico-primary);
}

.workspace-card h4 {
    margin: 0 0 0.25rem;
}

.workspace-card .ws-meta {
    font-size: 0.85rem;
    color: var(--pico-muted-color);
}

/* Document table */
.doc-table {
    font-size: 0.92rem;
}

.doc-table td,
.doc-table th {
    vertical-align: middle;
}

.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.actions form {
    margin: 0;
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
}

.btn-danger {
    --pico-background-color: #dc2626;
    --pico-border-color: #dc2626;
    --pico-color: #fff;
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* Nav tweaks */
nav .brand {
    font-weight: 700;
}

/* Form width limit */
.form-narrow {
    max-width: 480px;
}

/* Avatar dropdown menu */
.avatar-menu { position: relative; }

.avatar-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: none; background: #3b82f6; color: #fff;
    font-weight: 700; font-size: 0.9rem; cursor: pointer;
    line-height: 36px; padding: 0; text-align: center;
}

.avatar-dropdown {
    display: none; position: absolute; right: 0;
    top: calc(100% + 0.5rem); min-width: 220px;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100;
}

.avatar-menu.open .avatar-dropdown { display: block; }

.avatar-dropdown-header { display: flex; flex-direction: column; gap: 0.15rem; }
.avatar-dropdown-header strong { font-size: 0.95rem; }
.avatar-dropdown-header small { color: var(--pico-muted-color); font-size: 0.8rem; }
.avatar-dropdown-header .badge { margin-top: 0.25rem; align-self: flex-start; }
.avatar-dropdown hr { margin: 0.5rem 0; }
.avatar-dropdown a { display: block; font-size: 0.9rem; text-decoration: none; }

/* Upload hint */
.upload-hint {
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

/* Chat layout */
.chat-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    min-height: 70vh;
}

.chat-sidebar {
    border-right: 1px solid var(--pico-muted-border-color);
    padding-right: 1.25rem;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 50vh;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--pico-border-radius);
}

.conversation-item.active {
    background: var(--pico-primary-focus);
}

.conversation-item a {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    text-decoration: none;
}

.conv-delete {
    padding: 0.15rem 0.45rem;
    font-size: 0.8rem;
    line-height: 1;
    flex-shrink: 0;
}

/* Chat messages area */
.chat-main {
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-empty {
    color: var(--pico-muted-color);
    text-align: center;
    margin-top: 2rem;
}

.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--pico-border-radius);
    max-width: 80%;
}

.chat-bubble strong {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
}

.chat-user {
    background: #dbeafe;
    color: #1e3a5f;
    align-self: flex-end;
}

.chat-assistant {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    align-self: flex-start;
}

.chat-loading {
    opacity: 0.6;
}

/* Chat input bar */
.chat-input-bar {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--pico-muted-border-color);
}

.chat-input-bar input {
    flex: 1;
    margin-bottom: 0;
}

.chat-input-bar button {
    flex-shrink: 0;
    margin-bottom: 0;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .chat-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--pico-muted-border-color);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .conversation-list {
        max-height: 25vh;
    }

    .chat-messages {
        max-height: 45vh;
    }

    .chat-bubble {
        max-width: 95%;
    }
}

/* Equalizer "thinking" indicator */
.eq-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.eq-bar {
    display: inline-block;
    width: 4px;
    height: 100%;
    background: var(--pico-muted-color);
    border-radius: 2px;
    animation: eq-bounce 0.6s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { animation-delay: 0s; }
.eq-bar:nth-child(2) { animation-delay: 0.15s; }
.eq-bar:nth-child(3) { animation-delay: 0.3s; }
.eq-bar:nth-child(4) { animation-delay: 0.2s; }
.eq-bar:nth-child(5) { animation-delay: 0.1s; }

@keyframes eq-bounce {
    0%   { transform: scaleY(0.2); }
    100% { transform: scaleY(1.0); }
}
