/**
 * Estilos BEM del widget flotante de tickets (Soporte A2M).
 * Coherente con las variables de diseño medieval de aoe2mg-core.
 */

.atkt-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: var(--aoe2mg-font-body);
    box-sizing: border-box;
}

.atkt-widget *,
.atkt-widget *::before,
.atkt-widget *::after {
    box-sizing: border-box;
}

/* Lanzador flotante */
.atkt-launcher-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--aoe2mg-accent);
    color: var(--aoe2mg-bg);
    border: none;
    cursor: pointer;
    box-shadow: var(--aoe2mg-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s ease;
}

.atkt-launcher-btn:hover {
    transform: scale(1.1);
    background: #fdbf7f;
}

.atkt-launcher-btn i {
    display: block;
    line-height: 1;
}

/* Caja del cajón (Drawer) */
.atkt-drawer {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--aoe2mg-bg-alt);
    border: 1px solid var(--aoe2mg-border);
    border-radius: var(--aoe2mg-radius-lg);
    box-shadow: var(--aoe2mg-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    animation: atkt-fade-in 0.25s ease-out forwards;
}

@keyframes atkt-fade-in {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Encabezado del cajón */
.atkt-drawer-header {
    background: var(--aoe2mg-panel);
    border-bottom: 1px solid var(--aoe2mg-border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.atkt-drawer-header h3 {
    margin: 0;
    color: var(--aoe2mg-accent);
    font-family: var(--aoe2mg-font-display);
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.atkt-close-btn {
    background: none;
    border: none;
    color: var(--aoe2mg-text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.atkt-close-btn:hover {
    color: var(--aoe2mg-accent);
}

/* Cuerpo del cajón */
.atkt-drawer-body {
    padding: 16px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--aoe2mg-bg-alt);
}

/* Pantallas individuales */
.atkt-screen {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.atkt-screen.active {
    display: flex;
}

.atkt-welcome {
    color: var(--aoe2mg-text);
    font-size: 14px;
    line-height: 1.5;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

.atkt-subtext {
    font-size: 12px;
    color: var(--aoe2mg-text-muted);
    line-height: 1.4;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

.atkt-guest-search-area {
    margin-top: auto;
    border-top: 1px solid var(--aoe2mg-border);
    padding-top: 20px;
}

/* Inputs y Formularios */
#atkt-form-create,
#atkt-form-search {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* Scrollbar para formularios */
#atkt-form-create::-webkit-scrollbar,
#atkt-form-search::-webkit-scrollbar {
    width: 6px;
}
#atkt-form-create::-webkit-scrollbar-thumb,
#atkt-form-search::-webkit-scrollbar-thumb {
    background: var(--aoe2mg-border);
    border-radius: 3px;
}

.atkt-screen label {
    display: block;
    margin-bottom: 12px;
}

.atkt-screen label span {
    display: block;
    font-size: 11px;
    color: var(--aoe2mg-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.atkt-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--aoe2mg-panel-2);
    border: 1px solid var(--aoe2mg-border);
    border-radius: var(--aoe2mg-radius);
    color: var(--aoe2mg-text);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s ease;
}

.atkt-input:focus {
    border-color: var(--aoe2mg-accent);
    outline: none;
}

.atkt-textarea {
    min-height: 80px;
    max-height: 120px;
    resize: vertical;
}

/* Botones */
.atkt-btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--aoe2mg-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    font-family: inherit;
    display: block;
    width: 100%;
    margin-bottom: 10px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.atkt-btn:active {
    transform: scale(0.98);
}

.atkt-btn-primary {
    background: var(--aoe2mg-accent);
    color: var(--aoe2mg-bg);
}

.atkt-btn-primary:hover {
    background: #fdbf7f;
}

.atkt-btn-secondary {
    background: var(--aoe2mg-panel);
    border: 1px solid var(--aoe2mg-border);
    color: var(--aoe2mg-text);
}

.atkt-btn-secondary:hover {
    background: var(--aoe2mg-panel-2);
}

.atkt-btn-back {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--aoe2mg-text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    transition: color 0.15s ease;
}

.atkt-btn-back:hover {
    color: var(--aoe2mg-accent);
}

/* Captcha */
.atkt-captcha-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--aoe2mg-panel);
    border: 1px solid var(--aoe2mg-border);
    border-radius: var(--aoe2mg-radius);
    padding: 8px 12px;
    margin-bottom: 12px;
}

.atkt-captcha-wrapper label {
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.atkt-captcha-wrapper label span {
    margin: 0;
    text-transform: none;
    font-size: 13px;
    color: var(--aoe2mg-text);
    font-weight: normal;
    letter-spacing: 0;
}

.atkt-captcha-wrapper label strong {
    color: var(--aoe2mg-accent);
    font-size: 15px;
    margin-left: 4px;
}

.atkt-captcha-wrapper input {
    width: 60px;
    text-align: center;
    margin: 0;
    padding: 6px;
}

/* Listado de tickets */
.atkt-list-container {
    flex: 1;
    overflow-y: auto;
}

.atkt-list-container::-webkit-scrollbar {
    width: 6px;
}
.atkt-list-container::-webkit-scrollbar-thumb {
    background: var(--aoe2mg-border);
    border-radius: 3px;
}

.atkt-ticket-item {
    background: var(--aoe2mg-panel);
    border: 1px solid var(--aoe2mg-border);
    padding: 12px;
    border-radius: var(--aoe2mg-radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.atkt-ticket-item:hover {
    background: var(--aoe2mg-panel-2);
    border-color: var(--aoe2mg-accent);
}

.atkt-ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.atkt-ticket-title {
    font-weight: 600;
    color: var(--aoe2mg-text);
    font-size: 13px;
    margin: 0;
    padding-right: 8px;
}

.atkt-ticket-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.atkt-ticket-category {
    font-size: 11px;
    color: var(--aoe2mg-text-muted);
}

.atkt-ticket-date {
    font-size: 10px;
    color: var(--aoe2mg-text-muted);
}

/* Badges de estado */
.atkt-badge {
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    letter-spacing: 0.5px;
}

.atkt-badge--open,
.atkt-badge--abierto {
    background: var(--aoe2mg-danger);
    color: #fff;
}

.atkt-badge--in_progress,
.atkt-badge--proceso {
    background: var(--aoe2mg-accent);
    color: var(--aoe2mg-bg);
}

.atkt-badge--closed,
.atkt-badge--cerrado {
    background: var(--aoe2mg-brown);
    color: var(--aoe2mg-text);
}

/* Chat del ticket */
.atkt-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--aoe2mg-border);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.atkt-chat-title {
    margin: 0;
    font-size: 14px;
    color: var(--aoe2mg-text);
    font-family: var(--aoe2mg-font-display);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 230px;
}

.atkt-chat-key-info {
    font-size: 10px;
    color: var(--aoe2mg-text-muted);
    margin-bottom: 12px;
}

.atkt-chat-messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 8px;
    border: 1px solid var(--aoe2mg-border);
    border-radius: var(--aoe2mg-radius);
    background: var(--aoe2mg-bg);
    margin-bottom: 12px;
}

.atkt-chat-messages-container::-webkit-scrollbar {
    width: 6px;
}
.atkt-chat-messages-container::-webkit-scrollbar-thumb {
    background: var(--aoe2mg-border);
    border-radius: 3px;
}

.atkt-chat-bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: var(--aoe2mg-radius-lg);
    font-size: 12px;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Mensajes enviados por usuario o invitado */
.atkt-chat-bubble--user,
.atkt-chat-bubble--guest {
    align-self: flex-end;
    background: var(--aoe2mg-panel-2);
    color: var(--aoe2mg-text);
    border: 1px solid var(--aoe2mg-border);
    border-bottom-right-radius: 2px;
}

/* Mensajes del administrador */
.atkt-chat-bubble--admin {
    align-self: flex-start;
    background: #3c3026;
    color: var(--aoe2mg-text);
    border: 1px solid var(--aoe2mg-border);
    border-bottom-left-radius: 2px;
}

.atkt-chat-bubble--admin .atkt-bubble-sender {
    color: var(--aoe2mg-accent);
}

.atkt-bubble-sender {
    display: block;
    font-weight: bold;
    font-size: 10px;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.atkt-bubble-text {
    margin: 0;
}

.atkt-bubble-meta {
    font-size: 9px;
    color: var(--aoe2mg-text-muted);
    display: block;
    margin-top: 6px;
    text-align: right;
}

/* Responder en chat */
.atkt-chat-reply-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.atkt-chat-textarea {
    margin: 0;
    flex: 1;
    min-height: 40px;
    height: 40px;
    padding: 10px 12px;
    resize: none;
    font-family: inherit;
    font-size: 12px;
}

.atkt-btn-send {
    background: var(--aoe2mg-accent);
    border: none;
    color: var(--aoe2mg-bg);
    width: 40px;
    height: 40px;
    border-radius: var(--aoe2mg-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.atkt-btn-send:hover {
    background: #fdbf7f;
}

.atkt-btn-send:active {
    transform: scale(0.95);
}

.atkt-chat-closed-notice {
    background: var(--aoe2mg-panel);
    border: 1px solid var(--aoe2mg-border);
    border-radius: var(--aoe2mg-radius);
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--aoe2mg-text-muted);
    font-weight: 500;
}

/* Estados de carga / errores */
.atkt-loading,
.atkt-error {
    text-align: center;
    font-size: 13px;
    color: var(--aoe2mg-text-muted);
    padding: 20px 0;
}

.atkt-error {
    color: var(--aoe2mg-danger);
}
