/* ===== WRAPPER ===== */
.tao-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== SERVER CONTAINER ===== */
.server-container {
    display: flex;
    gap: 10px;
    margin: 15px 0 25px 0;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 14px;
    width: fit-content;
    border: 1px solid #e2e8f0;
}

.btn-server {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #475569;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-server .fi {
    width: 1.35em;
    line-height: 1em;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.btn-server.active {
    background: #ffffff;
    color: #0284c7;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* ===== CONTROLS (BÊN TRÁI) ===== */
.tao-controls {
    width: 440px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    /* 2 cột cho gọn (máy tính lẫn điện thoại) */
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    align-content: start;
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.1);
}

/* Các khối chiếm cả 2 cột */
.tao-controls > .search-box,
.tao-controls > .row-full,
.tao-controls > .switch-line,
.tao-controls > .action-buttons,
.tao-controls > .key-row {
    grid-column: 1 / -1;
}
.tao-controls select { width: 100%; min-width: 0; }

.tao-controls label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
}

.tao-controls select,
.tao-controls input[type="text"] {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 12px;
    border: 1px solid #bae6fd;
    outline: none;
    transition: .2s;
    color: #1e3a8a;
}

.tao-controls select:focus,
.tao-controls input[type="text"]:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.row-full {
    grid-column: 1 / -1 !important;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 5px;
}

.row-full label {
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
}

.input-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.input-group input {
    flex: 1;
    min-width: 0;
}

.btn-paste {
    padding: 0 20px;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
    -webkit-tap-highlight-color: transparent;
}

.btn-paste i,
#createBtn i,
#saveBtn i,
#keyBtn i,
.search-box label i,
.suggest-note i,
.key-modal-actions i {
    margin-right: 2px;
}

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

select.loading-data {
    background: #f8fafc;
    opacity: 0.5;
    pointer-events: none;
}

/* ===== SWITCH LINE ===== */
.switch-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 14px;
    background: #f0f9ff;
    color: #1d4ed8;
    font-size: 14px;
}

.switch {
    position: relative;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #bae6fd;
    border-radius: 999px;
    transition: .3s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.2);
}

.switch input:checked + .slider {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.switch.glow input:checked + .slider {
    box-shadow: 0 0 6px rgba(96, 165, 250, 0.8), 0 0 14px rgba(186, 230, 253, 0.9);
}

/* ===== ACTION BUTTONS (CÙNG 1 HÀNG) ===== */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

#createBtn,
#saveBtn {
    flex: 1;
    margin-top: 0 !important;
    padding: 12px 8px;
    border: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: .25s;
    text-align: center;
    white-space: nowrap;
}

#createBtn {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: #fff;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

#createBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 25px rgba(59, 130, 246, 0.45);
}

#saveBtn {
    background: #e0f2fe;
    color: #1d4ed8;
    border: 1px solid #bae6fd;
}

#saveBtn:hover {
    background: #bae6fd;
}

/* ===== Ô TÌM KIẾM TƯỚNG / SKIN ===== */
.search-box {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.search-input-wrap {
    position: relative;
}

.tao-controls .search-input-wrap input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding-right: 38px;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: #e0f2fe;
    color: #1d4ed8;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.search-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 14px;
    box-shadow: 0 14px 30px rgba(30, 64, 175, 0.18);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    -webkit-overflow-scrolling: touch;
}

.suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.suggest-item:last-of-type { border-bottom: none; }

.suggest-item:hover,
.suggest-item.active {
    background: #eff6ff;
}

.suggest-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
}

.suggest-badge.skin {
    background: #fef3c7;
    color: #b45309;
}

.suggest-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.suggest-main {
    font-size: 14px;
    font-weight: 600;
    color: #1e3a8a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggest-sub {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggest-note {
    padding: 10px 12px;
    font-size: 12.5px;
    color: #64748b;
    text-align: center;
    line-height: 1.4;
}

/* ===== NÚT XUẤT KEY ===== */
.key-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

#keyBtn {
    width: 100%;
    padding: 12px 8px;
    border-radius: 14px;
    border: 1px dashed #60a5fa;
    background: #f0f9ff;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: .25s;
    -webkit-tap-highlight-color: transparent;
}

#keyBtn:hover {
    background: #e0f2fe;
}

.key-hint {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    line-height: 1.4;
}

/* ===== HỘP THOẠI KEY ===== */
.key-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.key-modal {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.key-modal-title {
    font-weight: 700;
    font-size: 16px;
    color: #1e3a8a;
}

.key-modal-summary {
    font-size: 13px;
    font-weight: 600;
    color: #1d4ed8;
    background: #f0f9ff;
    border-radius: 10px;
    padding: 8px 10px;
    line-height: 1.4;
}

.key-modal-hint {
    font-size: 13px;
    color: #475569;
    line-height: 1.45;
}

.key-modal textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 96px;
    resize: none;
    padding: 10px 12px;
    font-size: 16px;
    font-family: Consolas, Menlo, monospace;
    border-radius: 12px;
    border: 1px solid #bae6fd;
    color: #1e3a8a;
    word-break: break-all;
    outline: none;
}

.key-modal-actions {
    display: flex;
    gap: 10px;
}

.key-modal-actions button {
    flex: 1;
    padding: 11px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.key-btn-copy {
    border: none;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: #fff;
}

.key-btn-close {
    border: 1px solid #bae6fd;
    background: #e0f2fe;
    color: #1d4ed8;
}

/* ===== PREVIEW (BÊN PHẢI) ===== */
.tao-preview {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tao-preview.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#preview,
#previewImage {
    max-width: 100%;
    border-radius: 16px;
    background: #f0f9ff;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.1), 0 0 12px rgba(96, 165, 250, 0.3);
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 58, 138, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 10;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 6px solid rgba(255, 255, 255, .2);
    border-top-color: #bae6fd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== TOAST NOTIFICATION ===== */
.toast-msg {
    position: fixed;
    top: 100px;
    right: -300px; 
    background: #fff;
    color: #1e3a8a;
    padding: 12px 20px;
    border-radius: 10px;
    border-left: 5px solid #22c55e; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    font-weight: 600;
    font-size: 14px;
    z-index: 9999;
    transition: right 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-msg.show {
    right: 20px; 
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .tao-wrapper {
        flex-direction: column;
    }
    .tao-controls {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .row-full, .action-buttons, .search-box, .key-row {
        grid-column: 1 / span 2 !important;
    }
}

/* ===== 3 CÔNG TẮC DỒN THÀNH 1 KHỐI LIỀN ===== */
.tao-controls .switch-line {
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 0;
    margin: -10px 0 0;
}
.tao-controls .row-full + .switch-line { margin-top: 0; border-radius: 12px 12px 0 0; }
.tao-controls .switch-line + .switch-line { border-top: 1px solid #e0f2fe; }
.tao-controls .switch-line:has(+ .action-buttons) { border-radius: 0 0 12px 12px; }
.tao-controls .switch { width: 40px; height: 22px; }
.tao-controls .slider::before { width: 16px; height: 16px; }
.tao-controls .switch input:checked + .slider::before { transform: translateX(18px); }
.tao-controls .row-full { margin-bottom: 0; gap: 4px; }
.tao-controls label { gap: 4px; }
.action-buttons { margin-top: 0; }
.key-hint { font-size: 11.5px; }