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

/* ===== SERVER CONTAINER ===== */
.server-container {
    display: flex;
    gap: 10px;
    margin: 0 0 20px 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.active {
    background: #ffffff;
    color: #0284c7;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* ===== CONTROLS (BÊN TRÁI) ===== */
.tao-controls {
    width: 420px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 18px;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.1);
}

.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;
    width: 100%;
}

.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;
}

/* ===== 2 CỘT DÙNG CHUNG (Hiệu ứng/Tuần + Cụm tướng) ===== */
.row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.row-2col > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* tránh select bị tràn */
}

/* Trên màn quá nhỏ thì cho về lại 1 cột cho dễ bấm */
@media (max-width: 360px) {
    .row-2col {
        grid-template-columns: 1fr;
    }
}

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

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

.btn-paste {
    padding: 0 16px;
    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:active { 
    transform: scale(0.95); 
}

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

/* Dynamic Cluster Item Style */
.cluster-item-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.cluster-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 13px;
    color: #0284c7;
    margin-bottom: 4px;
}

.btn-del-cluster {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-del-cluster:hover {
    background: #fca5a5;
    color: #b91c1c;
}

/* ===== 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;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

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

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

#createBtn:disabled {
    background: #cbd5e1 !important;
    color: #94a3b8 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}

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

#saveBtn:hover {
    background: #bae6fd;
}

/* ===== PREVIEW (BÊN PHẢI) ===== */
.tao-preview {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    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;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

#preview,
#previewImage {
    max-width: 100%;
    height: auto;
    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: repeat(2, 1fr);
        gap: 12px;
    }

    .row-full, 
    .action-buttons, 
    .server-container,
    .switch-line { 
        grid-column: 1 / -1 !important; 
    }
}

@media (max-width: 480px) {
    .tao-controls {
        padding: 14px 12px;
    }

    .tao-controls select,
    .tao-controls input[type="text"] {
        font-size: 13px;
        padding: 8px 10px;
    }

    .btn-paste {
        padding: 0 10px;
        font-size: 13px;
    }
}