/* ========== MANAGEMENT PAGE STYLES ========== */

.container {
    max-width: 60%;
    padding: 0;
    background: linear-gradient(135deg, #e2f2f4 0%, #f0f7ff 100%);
    min-height: 100vh;
}

/* ========== HEADER ========== */
.management-header {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
    padding: 16px;
    border-bottom: 3px solid #0066ff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.back-btn {
    background: linear-gradient(135deg, #8294b8, #405f8b);
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Prompt', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    justify-content: center;
}

.back-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    color: white;
}

.management-header h1 {
    color: #0055d5;
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-align: center;
    flex: 1;
}

.header-spacer {
    width: 80px;
    /* ความกว้างเท่ากับปุ่มกลับสำหรับจัดสมดุล */
}

/* ========== MAIN CONTENT ========== */
.management-main {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========== ADD BRANCH CARD ========== */
.add-branch-card {
    background: linear-gradient(135deg, #ffffff, #f0fff4);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-bottom: 5px solid #31cc23;
    animation: slideInDown 0.4s ease;
}

.add-branch-card h2 {
    color: #00c043;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.add-form input,
.add-form select {
    padding: 4px 16px;
    border: 2px solid #cbd5e0;
    border-radius: 10px;
    font-family: 'Prompt', sans-serif;
    font-size: 17px;
    transition: all 0.3s ease;
    background: #fafafa;
    width: 100%;
}

.add-form input:focus,
.add-form select:focus {
    outline: none;
    border-color: #0066ff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.input-hint {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.add-btn {
    background: linear-gradient(135deg, #029aff, #e100ff, #ffbb00);
    border-bottom: 4px solid #0000004b !important;
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 10px;
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 2px 4px 5px rgba(0, 26, 83, 0.301);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 3px 4px 8px rgba(1, 13, 122, 0.4);
}

.add-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========== BRANCHES SECTION ========== */
.branches-section {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.branches-section h3 {
    color: #0066ff;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Empty State */
.no-branches-message {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f8fafc, #f0f4ff);
    border-radius: 12px;
    border: 2px dashed #cbd5e0;
    color: #666;
}

.no-branches-message .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.no-branches-message p:first-of-type {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.no-branches-message p:last-of-type {
    font-size: 14px;
}

/* Branches List */
.branches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Branch Item */
.branch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #ffffff, #fafbff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    animation: slideInRight 0.4s ease;
}

.branch-item:hover {
    border-color: #0066ff;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.15);
}

.branch-info {
    display: flex;
    justify-content: space-between;
    /* ชื่อสาขาชิดซ้าย, พื้นที่ชิดขวา */
    align-items: center;
    flex: 1;
    gap: 16px;
}

.branch-name {
    font-weight: 600;
    color: #000242;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.branch-name::before {
    content: "🏢";
    font-size: 14px;
}

.branch-region {
    background: #0066ff;
    color: white;
    padding: 2px 0px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 65px;
    text-align: center;
}

.branch-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
}

.branch-actions button {
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 60px;
    justify-content: center;
}

.edit-btn {
    background: #f59e0b;
    color: white;
}

.edit-btn:hover {
    background: #d97706;
    transform: scale(1.05);
}

.delete-btn {
    background: #dc2626;
    color: white;
}

.delete-btn:hover {
    background: #b91c1c;
    transform: scale(1.05);
}

.delete-btn:hover {
    background: #b91c1c;
    transform: scale(1.05);
}

/* ========== SYSTEM ACTIONS ========== */
.system-actions {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.system-actions h3 {
    color: #0066ff;
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: 700;

    display: flex;
    align-items: center;
    gap: 8px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-btn {
    background: linear-gradient(135deg, #08d03a, #02b836);
    color: white;
    padding: 7px 0px !important;
}

.import-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    margin-top: -5px;
    padding: 7px 0px !important;

}

.danger-btn {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    margin-top: 10px;
    padding: 4px 20px !important;
    font-size: 16px !important;
    font-weight: 400 !important;
}

.action-buttons button {
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.action-buttons button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========== EDIT FORM STYLES ========== */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}

.edit-form .input-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

/* ========== ANIMATIONS ========== */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 480px) {

    .container {
        max-width: 100%;
        padding: 0;

        .management-header {
            padding: 12px;
            flex-direction: column;
            gap: 8px;
        }

        .back-btn {
            order: 1;
            width: 62%;
            border-radius: 25px;
            margin-top: 8px;
        }

        .management-header h1 {
            order: 0;
            font-size: 20px;
        }

        .header-spacer {
            display: none;
        }

        .management-main {
            padding: 16px 12px;
            gap: 20px;
        }

        .add-btn {
            background: linear-gradient(135deg, #029aff, #e100ff, #ffbb00);
            color: white;
            border: none;
            padding: 8px 24px;
            border-radius: 10px;
            font-family: 'Prompt', sans-serif;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 2px 4px 8px rgba(58, 121, 255, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-top: 2px;
        }


        .add-branch-card,
        .branches-section,
        .system-actions {
            padding: 20px 16px;
        }

        .branch-item {
            flex-direction: column;
            align-items: stretch;
            gap: 12px;
            padding: 14px;
        }

        .branch-actions {
            justify-content: center;
            flex-wrap: wrap;
        }

        .branch-item {
            flex-direction: column;
            align-items: stretch;
            gap: 12px;
            padding: 14px;
        }

        .branch-info {
            flex-direction: row;
            justify-content: space-between;
            gap: 8px;
        }

        .branch-name {
            font-size: 18px;
            flex: none;
        }

        .branch-region {
            font-size: 12px;
            padding: 2px 5px;
            min-width: 50px;
        }

        .branch-actions {
            /* 💥 3 บรรทัดนี้ คือคำสั่งหลัก 💥 */
            display: flex;
            justify-content: flex-end;
            align-items: center;
            gap: 8px;
            margin-left: 0;
            width: 100%;
        }

        .branch-actions button {
            padding: 2px 2px;
            font-size: 14px;
            border-radius: 30px;
            min-width: 80px;
            max-width: 80px;
            gap: 2px;
            min-height: 0 !important;
            /* สั่งยกเลิกความสูงขั้นต่ำทั้งหมด */
            height: 28px !important;
        }
    }

    /* Utility Classes */
    .hidden {
        display: none !important;
    }

    /* Drag and Drop Styles */
    .branch-item.dragging {
        opacity: 0.5;
        background: #f0f4ff;
    }

    .branch-item.drag-over {
        border: 2px dashed #0066ff;
        background: #f0f7ff;
    }

    .move-handle {
        cursor: grab;
        padding: 8px;
        border-radius: 6px;
        background: #f1f5f9;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .move-handle:active {
        cursor: grabbing;
    }

    .move-handle:hover {
        background: #e2e8f0;
    }
}

/* ==== MANAGE PAGE FOOTER ==== */
#footerArea {
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
    font-size: 14px;
    color: #555;
    background: #f7f9fb;
    border-top: 2px solid #e0e0e0;
}

#footerArea .credit a {
    color: #0066ff;
    font-weight: 600;
}

#footerArea .credit {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

/* ทำให้ footer ตรึงแบบไม่เกะกะ แต่เห็นง่ายบนมือถือ */
@media (max-width: 768px) {
    #footerArea {
        position: sticky;
        bottom: 0;
        background: #ffffffee;
        backdrop-filter: blur(5px);
        padding: 14px 0;
        border-top: 2px solid #d2d2d2;
    }
}
