/* ============================================================
   BLAGOWEB CLIENT PORTAL — Frontend CSS
   ============================================================ */

:root {
    --blp-primary: #667eea;
    --blp-primary-dk: #4a5fd4;
    --blp-secondary: #764ba2;
    --blp-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --blp-success: #27ae60;
    --blp-warning: #e67e22;
    --blp-danger: #e74c3c;
    --blp-info: #3498db;
    --blp-text: #2d3748;
    --blp-text-muted: #718096;
    --blp-bg: #f7f8fc;
    --blp-white: #ffffff;
    --blp-border: #e2e8f0;
    --blp-radius: 12px;
    --blp-radius-sm: 8px;
    --blp-shadow: 0 4px 24px rgba(102, 126, 234, 0.10);
    --blp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.07);
    --blp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.blp-wrap * {
    box-sizing: border-box;
}

.blp-wrap {
    font-family: var(--blp-font);
    color: var(--blp-text);
    line-height: 1.6;
    background: var(--blp-bg);
    min-height: 100vh;
}

/* ============================================================
   LOGIN
   ============================================================ */
#blp-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 24px;
    background: var(--blp-gradient);
}

.blp-login-card {
    background: var(--blp-white);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: blp-fade-up 0.4s ease;
}

.blp-login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.blp-logo {
    max-height: 52px;
    max-width: 200px;
    object-fit: contain;
}

.blp-login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--blp-text);
    margin: 0 0 8px 0;
    text-align: center;
}

.blp-login-subtitle {
    color: var(--blp-text-muted);
    font-size: 0.9rem;
    text-align: center;
    margin: 0 0 28px 0;
}

.blp-login-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--blp-text-muted);
    margin-top: 20px;
}

.blp-login-footer a {
    color: var(--blp-primary);
    text-decoration: none;
}

.blp-step {
    animation: blp-fade-up 0.3s ease;
}

/* OTP input special */
.blp-input--otp {
    text-align: center;
    font-size: 2rem !important;
    letter-spacing: 0.5em;
    font-weight: 700 !important;
    color: var(--blp-primary) !important;
}

.blp-otp-resend {
    text-align: center;
    font-size: 0.85rem;
    color: var(--blp-text-muted);
    margin-top: 16px;
}

.blp-back-btn {
    background: none;
    border: none;
    color: var(--blp-primary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    margin-bottom: 16px;
    font-family: var(--blp-font);
}

.blp-back-btn:hover {
    text-decoration: underline;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.blp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--blp-white);
    padding: 12px 24px;
    border-bottom: 1px solid var(--blp-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--blp-shadow-sm);
}

.blp-topbar-logo {
    max-height: 36px;
    object-fit: contain;
}

.blp-topbar-center {
    flex: 1;
    max-width: 640px;
}

.blp-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.blp-topbar-company {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--blp-text);
    white-space: nowrap;
}

.blp-topbar-btn {
    background: none;
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--blp-text-muted);
    position: relative;
    font-family: var(--blp-font);
    transition: all 0.2s;
}

.blp-topbar-btn:hover {
    background: var(--blp-bg);
    color: var(--blp-text);
}

.blp-logout-btn:hover {
    border-color: var(--blp-danger);
    color: var(--blp-danger);
}

.blp-notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--blp-danger);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ============================================================
   AI SEARCH BAR
   ============================================================ */
/* AI CHAT TRIGGER BAR */
.blp-ai-searchbar {
    display: flex;
    align-items: center;
    background: var(--blp-white);
    border: 1.5px solid var(--blp-border);
    border-radius: 50px;
    padding: 7px 12px 7px 16px;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.blp-ai-searchbar:hover {
    border-color: var(--blp-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.10);
}

.blp-ai-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.blp-ai-placeholder {
    flex: 1;
    font-size: 0.875rem;
    color: var(--blp-text-muted);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blp-ai-badge {
    background: var(--blp-gradient);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 50px;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

/* AI CHAT PANEL */
.blp-ai-chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 80px);
    background: var(--blp-white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(102, 126, 234, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: blp-chat-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes blp-chat-in {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(30px);
    }

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

/* CHAT HEADER */
.blp-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--blp-gradient);
    color: white;
    flex-shrink: 0;
}

.blp-ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.blp-ai-chat-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.blp-ai-chat-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.blp-ai-chat-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 2px;
}

.blp-ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.blp-ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* CHAT MESSAGES */
.blp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.blp-ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.blp-ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.blp-ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--blp-border);
    border-radius: 4px;
}

/* CHAT MESSAGES - BUBBLES */
.blp-ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: blp-msg-in 0.2s ease;
}

@keyframes blp-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.blp-ai-msg--bot {
    flex-direction: row;
}

.blp-ai-msg--user {
    flex-direction: row-reverse;
}

.blp-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blp-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    color: white;
}

.blp-ai-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.blp-ai-msg--bot .blp-ai-msg-bubble {
    background: #f0f2f8;
    color: var(--blp-text);
    border-bottom-left-radius: 4px;
}

.blp-ai-msg--user .blp-ai-msg-bubble {
    background: var(--blp-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.blp-ai-typing .blp-ai-msg-bubble {
    padding: 12px 16px;
}

.blp-ai-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.blp-ai-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--blp-text-muted);
    border-radius: 50%;
    animation: blp-dot 1.2s infinite;
}

.blp-ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.blp-ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blp-dot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* CHAT FOOTER */
.blp-ai-chat-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--blp-border);
    flex-shrink: 0;
    background: var(--blp-white);
}

.blp-ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--blp-bg);
    border: 1.5px solid var(--blp-border);
    border-radius: 16px;
    padding: 8px 8px 8px 14px;
    transition: border-color 0.2s;
}

.blp-ai-chat-input-wrap:focus-within {
    border-color: var(--blp-primary);
}

.blp-ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--blp-text);
    font-family: var(--blp-font);
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.5;
}

.blp-ai-chat-input::placeholder {
    color: var(--blp-text-muted);
}

.blp-ai-send-btn {
    background: var(--blp-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}

.blp-ai-send-btn:hover:not(:disabled) {
    opacity: 0.85;
    transform: scale(1.05);
}

.blp-ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.blp-ai-chat-hint {
    font-size: 0.7rem;
    color: var(--blp-text-muted);
    text-align: center;
    margin-top: 6px;
}

/* Error message in chat */
.blp-ai-msg-error .blp-ai-msg-bubble {
    background: #ffeaea;
    color: #c0392b;
}

@media (max-width: 480px) {
    .blp-ai-chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        border-radius: 20px 20px 0 0;
        height: 80vh;
    }
}


/* ============================================================
   NOTIFICHE PANEL
   ============================================================ */
.blp-notif-panel {
    position: fixed;
    top: 62px;
    right: 16px;
    width: 360px;
    max-height: 480px;
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: blp-fade-up 0.2s ease;
}

.blp-notif-header {
    padding: 14px 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--blp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.blp-notif-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.blp-notif-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

.blp-notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--blp-border);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.blp-notif-item:last-child {
    border-bottom: none;
}

.blp-notif-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.blp-notif-body {
    flex: 1;
}

.blp-notif-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.blp-notif-message {
    font-size: 0.82rem;
    color: var(--blp-text-muted);
    margin-top: 2px;
}

.blp-notif-item--danger .blp-notif-icon::before {
    content: '';
}

.blp-notif-empty {
    text-align: center;
    padding: 32px;
    color: var(--blp-text-muted);
    font-size: 0.9rem;
}

/* ============================================================
   TABS
   ============================================================ */
.blp-tabs-nav {
    display: flex;
    background: var(--blp-white);
    border-bottom: 2px solid var(--blp-border);
    padding: 0 24px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.blp-tabs-nav::-webkit-scrollbar {
    display: none;
}

.blp-tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--blp-text-muted);
    white-space: nowrap;
    position: relative;
    font-family: var(--blp-font);
    transition: all 0.2s;
}

.blp-tab-btn:hover {
    color: var(--blp-primary);
}

.blp-tab-btn--active {
    color: var(--blp-primary);
    border-bottom-color: var(--blp-primary);
    font-weight: 700;
}

.blp-tab-badge {
    background: var(--blp-danger);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.blp-tabs-content {
    padding: 24px;
}

.blp-tab-panel {
    display: none;
    animation: blp-fade-up 0.25s ease;
}

.blp-tab-panel--active {
    display: block;
}

/* ============================================================
   PANEL HEADER
   ============================================================ */
.blp-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.blp-panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--blp-text);
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.blp-table-wrap {
    overflow-x: auto;
    border-radius: var(--blp-radius);
    border: 1px solid var(--blp-border);
}

.blp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.blp-table thead {
    background: var(--blp-bg);
}

.blp-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--blp-text-muted);
    border-bottom: 1px solid var(--blp-border);
    white-space: nowrap;
}

.blp-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--blp-border);
    vertical-align: top;
}

.blp-table tbody tr:last-child td {
    border-bottom: none;
}

.blp-table tbody tr:hover {
    background: #f8f9ff;
}

.blp-table-empty {
    text-align: center;
    padding: 40px !important;
    color: var(--blp-text-muted);
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.blp-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.blp-badge--active,
.blp-badge--paid,
.blp-badge--signed {
    background: #d4edda;
    color: #155724;
}

.blp-badge--draft,
.blp-badge--pending {
    background: #d1ecf1;
    color: #0c5460;
}

.blp-badge--expired,
.blp-badge--overdue,
.blp-badge--danger {
    background: #f8d7da;
    color: #721c24;
}

.blp-badge--warning,
.blp-badge--sent {
    background: #fff3cd;
    color: #856404;
}

.blp-badge--cancelled {
    background: #e2e3e5;
    color: #383d41;
}

/* ============================================================
   CONTRATTI
   ============================================================ */
.blp-contract-card {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--blp-shadow-sm);
    transition: box-shadow 0.2s;
}

.blp-contract-card:hover {
    box-shadow: var(--blp-shadow);
}

.blp-contract-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.blp-contract-number {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--blp-primary);
}

.blp-contract-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.blp-contract-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 4px 0;
}

.blp-contract-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--blp-text-muted);
    margin-top: 10px;
}

.blp-contract-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.blp-contract-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
}

/* ============================================================
   PAGAMENTI
   ============================================================ */
.blp-subsection-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--blp-border);
    margin-bottom: 20px;
}

.blp-sub-tab {
    padding: 8px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--blp-text-muted);
    font-family: var(--blp-font);
    transition: all 0.2s;
}

.blp-sub-tab--active {
    color: var(--blp-primary);
    border-bottom-color: var(--blp-primary);
    font-weight: 700;
}

.blp-sub-tab:hover {
    color: var(--blp-primary);
}

/* ============================================================
   DOCUMENTI
   ============================================================ */
.blp-doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.blp-doc-card {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--blp-text);
}

.blp-doc-card:hover {
    box-shadow: var(--blp-shadow);
    border-color: var(--blp-primary);
    color: var(--blp-text);
}

.blp-doc-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: block;
}

.blp-doc-name {
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-word;
}

.blp-doc-meta {
    font-size: 0.8rem;
    color: var(--blp-text-muted);
    margin-top: 4px;
}

/* ============================================================
   SERVIZI
   ============================================================ */
.blp-services-section {
    margin-bottom: 28px;
}

.blp-services-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--blp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
}

.blp-service-card {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 18px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.blp-service-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.blp-service-domain {
    font-size: 0.85rem;
    color: var(--blp-text-muted);
}

.blp-service-meta {
    font-size: 0.82rem;
    color: var(--blp-text-muted);
}

/* ============================================================
   TICKET
   ============================================================ */
.blp-ticket-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.blp-filter-chip {
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid var(--blp-border);
    background: var(--blp-white);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--blp-text-muted);
    font-family: var(--blp-font);
    transition: all 0.2s;
}

.blp-filter-chip:hover,
.blp-filter-chip--active {
    background: var(--blp-primary);
    color: white;
    border-color: var(--blp-primary);
}

.blp-ticket-item {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.blp-ticket-item:hover {
    border-color: var(--blp-primary);
    box-shadow: var(--blp-shadow);
}

.blp-ticket-item--has-unread {
    border-left: 4px solid var(--blp-primary);
}

.blp-ticket-number {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--blp-primary);
}

.blp-ticket-subject {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 2px 0;
}

.blp-ticket-meta {
    font-size: 0.82rem;
    color: var(--blp-text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* STATUS BADGES TICKET */
.blp-badge--open {
    background: #fef3c7;
    color: #92400e;
}

.blp-badge--waiting_client {
    background: #dbeafe;
    color: #1e40af;
}

.blp-badge--waiting_agent {
    background: #fce7f3;
    color: #9d174d;
}

.blp-badge--resolved {
    background: #d1fae5;
    color: #065f46;
}

.blp-badge--closed {
    background: #e5e7eb;
    color: #374151;
}

/* TICKET DETAIL VIEW */
.blp-ticket-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 480px;
    overflow-y: auto;
    padding: 4px 0;
}

.blp-msg-bubble {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.blp-msg-bubble--client {
    align-self: flex-end;
    align-items: flex-end;
}

.blp-msg-bubble--agent,
.blp-msg-bubble--system {
    align-self: flex-start;
    align-items: flex-start;
}

.blp-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.blp-msg-bubble--client .blp-msg-content {
    background: var(--blp-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.blp-msg-bubble--agent .blp-msg-content {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    color: var(--blp-text);
    border-bottom-left-radius: 4px;
}

.blp-msg-bubble--system .blp-msg-content {
    background: var(--blp-bg);
    border: 1px dashed var(--blp-border);
    color: var(--blp-text-muted);
    font-size: 0.82rem;
    border-radius: 8px;
}

.blp-msg-meta {
    font-size: 0.75rem;
    color: var(--blp-text-muted);
    margin-top: 4px;
}

.blp-msg-attachments {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.blp-msg-attachment {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--blp-bg);
    border: 1px solid var(--blp-border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--blp-primary);
    font-size: 0.82rem;
    font-weight: 500;
}

.blp-msg-attachment:hover {
    background: var(--blp-border);
}

.blp-ticket-reply-form {
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 20px;
    margin-top: 20px;
}

.blp-ticket-reply-form h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
}

.blp-closed-notice {
    background: #f8f9fa;
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 16px;
    text-align: center;
    color: var(--blp-text-muted);
    font-size: 0.9rem;
    margin-top: 20px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.blp-form-group {
    margin-bottom: 20px;
}

.blp-form-group--full {
    width: 100%;
}

.blp-form-row {
    display: flex;
    gap: 16px;
}

.blp-form-row .blp-form-group {
    flex: 1;
    min-width: 0;
}

.blp-label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
    color: var(--blp-text);
}

.blp-input,
.blp-select,
.blp-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--blp-border);
    border-radius: var(--blp-radius-sm);
    font-size: 0.95rem;
    font-family: var(--blp-font);
    color: var(--blp-text);
    background: var(--blp-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.blp-input:focus,
.blp-select:focus,
.blp-textarea:focus {
    border-color: var(--blp-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.blp-textarea {
    resize: vertical;
    min-height: 120px;
}

/* FILE DROP */
.blp-file-drop {
    border: 2px dashed var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    background: var(--blp-bg);
}

.blp-file-drop:hover,
.blp-file-drop--over {
    border-color: var(--blp-primary);
    background: #f0f3ff;
}

.blp-file-drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.blp-file-drop p {
    margin: 0;
    color: var(--blp-text-muted);
    font-size: 0.9rem;
}

.blp-file-list {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.blp-file-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--blp-white);
    border: 1px solid var(--blp-border);
    border-radius: 50px;
    font-size: 0.82rem;
}

.blp-file-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--blp-danger);
    padding: 0;
    font-size: 0.9rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.blp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--blp-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--blp-font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.blp-btn--primary {
    background: var(--blp-gradient);
    color: white;
}

.blp-btn--primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.blp-btn--secondary {
    background: var(--blp-white);
    color: var(--blp-text);
    border: 1.5px solid var(--blp-border);
}

.blp-btn--secondary:hover {
    border-color: var(--blp-primary);
    color: var(--blp-primary);
}

.blp-btn--outline {
    background: transparent;
    color: var(--blp-primary);
    border: 1.5px solid var(--blp-primary);
}

.blp-btn--outline:hover {
    background: var(--blp-primary);
    color: white;
}

.blp-btn--full {
    width: 100%;
}

.blp-btn--lg {
    padding: 13px 28px;
    font-size: 1rem;
}

.blp-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.blp-link-btn {
    background: none;
    border: none;
    color: var(--blp-primary);
    cursor: pointer;
    font-size: inherit;
    font-family: var(--blp-font);
    text-decoration: underline;
    padding: 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
.blp-alert {
    padding: 12px 16px;
    border-radius: var(--blp-radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.blp-alert--error {
    background: #fdf2f2;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.blp-alert--success {
    background: #f0fff4;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.blp-alert--info {
    background: #ebf8ff;
    color: #1a365d;
    border: 1px solid #bee3f8;
}

.blp-alert--warning {
    background: #fffbeb;
    color: #744210;
    border: 1px solid #f6e05e;
}

/* ============================================================
   SKELETON / LOADING
   ============================================================ */
.blp-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: blp-skeleton 1.4s infinite;
    border-radius: var(--blp-radius);
    height: 120px;
    width: 100%;
}

.blp-loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: var(--blp-text-muted);
}

.blp-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--blp-text-muted);
}

.blp-empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.blp-empty-text {
    font-size: 0.95rem;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes blp-fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes blp-skeleton {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .blp-topbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 16px;
    }

    .blp-topbar-center {
        order: 3;
        width: 100%;
    }

    .blp-topbar-right {
        gap: 8px;
    }

    .blp-topbar-company {
        display: none;
    }

    .blp-tabs-nav {
        padding: 0 16px;
    }

    .blp-tab-btn span {
        display: none;
    }

    .blp-tab-btn {
        padding: 12px 14px;
        font-size: 1.1rem;
    }

    .blp-tabs-content {
        padding: 16px;
    }

    .blp-form-row {
        flex-direction: column;
    }

    .blp-login-card {
        padding: 32px 24px;
    }

    .blp-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .blp-notif-panel {
        width: calc(100vw - 32px);
        right: 16px;
    }

    .blp-msg-bubble {
        max-width: 92%;
    }

    .blp-table th:nth-child(n+4) {
        display: none;
    }
}

@media (max-width: 480px) {
    .blp-tabs-content {
        padding: 12px;
    }

    .blp-contract-card,
    .blp-ticket-item {
        padding: 14px;
    }
}

/* ================================================================
   DISDETTA BOX
   ================================================================ */
.blp-disdetta-box {
    margin: 12px 0 4px;
    padding: 12px 14px;
    background: #fffbf0;
    border: 1px solid #ffe08a;
    border-radius: 8px;
    font-size: .88rem;
}

.blp-disdetta-box--sent {
    background: #f0fff4;
    border-color: #b7ebc8;
}

.blp-disdetta-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    color: var(--blp-text-muted);
}

.blp-disdetta-info strong {
    color: var(--blp-text);
    font-size: .92rem;
}

.blp-disdetta-expired {
    color: #dc3545 !important;
}

.blp-disdetta-sent {
    color: #28a745;
    font-weight: 500;
}

.blp-btn--danger {
    background: transparent;
    color: #dc3545;
    border-color: #dc3545;
}

.blp-btn.blp-btn--outline.blp-btn--danger:hover,
.blp-btn.blp-btn--danger:hover {
    background: #dc3545 !important;
    color: #fff !important;
    border-color: #dc3545;
    opacity: 1;
}

.blp-disdetta-form {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ffe08a;
}

.blp-disdetta-reason {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--blp-border);
    border-radius: 6px;
    font-size: .88rem;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.blp-disdetta-reason:focus {
    outline: none;
    border-color: var(--blp-primary);
}

.blp-disdetta-actions {
    margin-top: 10px;
}

.blp-disdetta-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.blp-disdetta-error {
    margin-top: 8px;
    padding: 6px 10px;
    background: #ffeaea;
    border-radius: 6px;
    color: #c0392b;
    font-size: .85rem;
}

.blp-hidden {
    display: none !important;
}

/* ================================================================
   PROGETTI / WORKFLOW
   ================================================================ */

.blp-project-card {
    background: var(--blp-surface);
    border: 1px solid var(--blp-border);
    border-radius: var(--blp-radius);
    padding: 20px;
    margin-bottom: 16px;
}

.blp-project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

.blp-project-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--blp-text);
    margin-bottom: 4px;
}

.blp-project-meta {
    display: flex;
    gap: 14px;
    font-size: .82rem;
    color: var(--blp-text-muted);
    flex-wrap: wrap;
}

/* Progress */
.blp-project-progress {
    margin-bottom: 18px;
}

.blp-project-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.blp-project-percent {
    font-size: 1.3rem;
    font-weight: 800;
}

.blp-project-phases {
    font-size: .82rem;
    color: var(--blp-text-muted);
}

.blp-project-bar {
    background: #e8e8e8;
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
}

.blp-project-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width .6s ease;
}

.blp-project-est {
    font-size: .8rem;
    color: var(--blp-text-muted);
    margin-top: 6px;
}

/* Phase list */
.blp-phase-list {
    border-top: 1px solid var(--blp-border);
    padding-top: 12px;
}

.blp-phase-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: .88rem;
}

.blp-phase-item:last-child {
    border-bottom: none;
}

.blp-phase-icon {
    font-size: .95rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.blp-phase-name {
    flex: 1;
    min-width: 0;
    color: var(--blp-text);
}

.blp-phase--done .blp-phase-name {
    text-decoration: line-through;
    color: var(--blp-text-muted);
}

.blp-phase--current {
    background: #f0f7ff;
    margin: 0 -12px;
    padding: 7px 12px;
    border-radius: 6px;
    border-bottom: none;
}

.blp-phase--current .blp-phase-name {
    font-weight: 600;
    color: var(--blp-primary);
}

.blp-phase--action {
    background: #fffbf0;
    margin: 0 -12px;
    padding: 7px 12px;
    border-radius: 6px;
}

.blp-phase-milestone {
    font-size: .8rem;
}

.blp-phase-action-tag {
    font-size: .7rem;
    background: #fff3cd;
    color: #856404;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.blp-phase-date {
    font-size: .78rem;
    color: var(--blp-text-muted);
    white-space: nowrap;
}

.blp-phase-file {
    font-size: .78rem;
    color: var(--blp-primary);
    text-decoration: none;
    white-space: nowrap;
}

.blp-phase-file:hover {
    text-decoration: underline;
}

/* Updates */
.blp-project-updates {
    border-top: 1px solid var(--blp-border);
    margin-top: 14px;
    padding-top: 12px;
}

.blp-project-updates-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--blp-text);
    margin-bottom: 10px;
}

.blp-update-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f8f8f8;
}

.blp-update-item:last-child {
    border-bottom: none;
}

.blp-update-icon {
    font-size: .9rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.blp-update-body {
    flex: 1;
    min-width: 0;
}

.blp-update-msg {
    font-size: .84rem;
    color: var(--blp-text);
    line-height: 1.4;
}

.blp-update-meta {
    font-size: .75rem;
    color: var(--blp-text-muted);
    margin-top: 2px;
}

/* ================================================================
   WORKFLOW — Interazione Cliente
   ================================================================ */

.blp-phase-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.blp-phase-approved-tag {
    font-size: .7rem;
    background: #d4edda;
    color: #155724;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.blp-phase-changes-tag {
    font-size: .7rem;
    background: #fff3cd;
    color: #856404;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

/* Interact area */
.blp-phase-interact {
    margin-top: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed var(--blp-border);
}

.blp-phase-description {
    font-size: .83rem;
    color: var(--blp-text-muted);
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #fff;
    border-radius: 6px;
    border-left: 3px solid var(--blp-primary);
}

/* Approval buttons */
.blp-phase-approval-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

/* Form */
.blp-phase-form {
    margin-top: 8px;
}

.blp-phase-comment {
    width: 100%;
    border: 1px solid var(--blp-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .85rem;
    resize: vertical;
    min-height: 42px;
    font-family: inherit;
}

.blp-phase-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.blp-upload-label {
    cursor: pointer;
}

.blp-phase-file-name {
    font-size: .8rem;
    color: var(--blp-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blp-btn--sm {
    padding: 5px 12px !important;
    font-size: .8rem !important;
}

.blp-btn--warning {
    color: #856404 !important;
    border-color: #ffc107 !important;
}

.blp-btn--warning:hover {
    background: #fff3cd !important;
}

/* Client actions already submitted */
.blp-phase-client-actions {
    margin-top: 8px;
    padding-left: 30px;
}

.blp-client-action-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: .82rem;
}

.blp-client-action-item:last-child {
    border-bottom: none;
}

.blp-ca-msg {
    color: var(--blp-text);
    line-height: 1.3;
}

.blp-ca-file {
    color: var(--blp-primary);
    text-decoration: none;
    font-size: .78rem;
}

.blp-ca-file:hover {
    text-decoration: underline;
}

.blp-ca-date {
    font-size: .72rem;
    color: var(--blp-text-muted);
    margin-top: 2px;
}