/* =========================================================
   Support Ticket - Floating Button & Modal (v2)
   ========================================================= */

.support-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #343ef3;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(52, 62, 243, 0.35);
    z-index: 9999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.support-fab:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(52, 62, 243, 0.45);
}

/* ===== Overlay ===== */
.support-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.support-modal-overlay.active {
    display: flex;
}

/* ===== Modal Box ===== */
.support-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    height: 90vh;
    max-height: 640px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: supportModalIn 0.25s ease;
    overflow: hidden;
}

@keyframes supportModalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Header ===== */
.support-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.support-modal__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.support-modal__close {
    background: none;
    border: none;
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.support-modal__close:hover {
    color: #374151;
}

/* ===== Body ===== */
.support-modal__body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== Views ===== */
.support-view {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.support-view.active {
    display: flex;
}

/* ===== Ticket List View ===== */
.support-tickets-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.support-tickets-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.support-tickets-empty i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.4;
}

.support-ticket-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.support-ticket-item:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.support-ticket-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.support-ticket-item__icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.support-ticket-item__icon.open {
    background: #dbeafe;
    color: #2563eb;
}

.support-ticket-item__icon.closed {
    background: #f3f4f6;
    color: #6b7280;
}

.support-ticket-item__info {
    flex: 1;
    min-width: 0;
}

.support-ticket-item__subject {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-ticket-item__meta {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.support-ticket-item__status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.support-ticket-item__status.open {
    background: #dcfce7;
    color: #166534;
}

.support-ticket-item__status.closed {
    background: #f3f4f6;
    color: #6b7280;
}

/* ===== New Ticket View ===== */
.support-new-ticket {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.support-new-ticket__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.support-new-ticket__back {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.support-new-ticket__back:hover {
    color: #1f2937;
}

.support-new-ticket__header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.support-form-group {
    margin-bottom: 16px;
}

.support-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.support-form-group input,
.support-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #1f2937;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
    box-sizing: border-box;
}

.support-form-group input:focus,
.support-form-group textarea:focus {
    outline: none;
    border-color: #343ef3;
    box-shadow: 0 0 0 3px rgba(52, 62, 243, 0.12);
    background: #fff;
}

.support-form-group textarea {
    min-height: 120px;
}

/* ===== Chat View ===== */
.support-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.support-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.support-chat__back {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.support-chat__back:hover {
    color: #1f2937;
}

.support-chat__header-info {
    flex: 1;
    min-width: 0;
}

.support-chat__header-subject {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-chat__header-status {
    font-size: 0.72rem;
    margin-top: 2px;
}

.support-chat__header-status.open {
    color: #16a34a;
}

.support-chat__header-status.closed {
    color: #6b7280;
}

/* Messages area */
.support-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.support-chat__messages-empty {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* Message bubble */
.support-msg-bubble {
    max-width: 78%;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
}

.support-msg-bubble .msg-time {
    display: inline-block;
    font-size: 0.65rem;
    color: #9ca3af;
    margin-right: 6px;
    vertical-align: bottom;
}

/* User message (right, blue) */
.support-msg-bubble.user {
    align-self: flex-end;
    background: #343ef3;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.support-msg-bubble.user .msg-time {
    color: rgba(255, 255, 255, 0.6)
}

/* Admin message (left, white) */
.support-msg-bubble.admin {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* System message (center) */
.support-msg-bubble.system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.78rem;
    padding: 6px 14px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
}

/* Input area */
.support-chat__input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.support-chat__input textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.88rem;
    font-family: inherit;
    color: #1f2937;
    background: #f9fafb;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.support-chat__input textarea:focus {
    outline: none;
    border-color: #343ef3;
    background: #fff;
}

.support-chat__input textarea:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.support-chat__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: #343ef3;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.support-chat__send:hover {
    background: #2a33d4;
}

.support-chat__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Closed notice */
.support-chat__closed-notice {
    text-align: center;
    padding: 10px 16px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.82rem;
    font-weight: 500;
    border-top: 1px solid #fecaca;
    flex-shrink: 0;
}

/* ===== Not Logged In ===== */
.support-not-logged {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
}

.support-not-logged.active {
    display: flex;
}

.support-not-logged i {
    font-size: 48px;
    color: #f59e0b;
}

.support-not-logged p {
    color: #6b7280;
    font-size: 0.92rem;
    line-height: 1.6;
}

.support-not-logged a {
    color: #343ef3;
    font-weight: 600;
    text-decoration: none;
}

.support-not-logged a:hover {
    text-decoration: underline;
}

/* ===== Message Box (error/success) ===== */
.support-msg-box {
    display: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    margin: 8px 16px;
    line-height: 1.5;
}

.support-msg-box.error {
    display: block;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.support-msg-box.success {
    display: block;
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ===== Loading spinner in modal ===== */
.support-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #9ca3af;
    font-size: 0.9rem;
    gap: 8px;
}

.support-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #343ef3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
    .support-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .support-modal {
        max-width: 100%;
        height: 95vh;
        max-height: 100%;
        border-radius: 14px;
    }

    .support-msg-bubble {
        max-width: 85%;
    }
}
/* ===== FAB Badge (Notification) ===== */
.support-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    border-radius: 11px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    border: 2px solid #fff;
    animation: badgePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    z-index: 10;
}

.support-fab__badge.hidden {
    display: none;
}

@keyframes badgePop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Pulse when badge appears */
.support-fab__badge.pulse {
    animation: badgePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
               badgePulse 2s ease-in-out 0.3s infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 2px 16px rgba(239, 68, 68, 0.7); }
}